Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radio/checkbox error prompt is displayed at every option #447

Open
PhilippGrashoff opened this issue Apr 17, 2018 · 4 comments
Open

Radio/checkbox error prompt is displayed at every option #447

PhilippGrashoff opened this issue Apr 17, 2018 · 4 comments

Comments

@PhilippGrashoff
Copy link
Collaborator

PhilippGrashoff commented Apr 17, 2018

When using return $from->error() with a radio field, the error message is displayed on every radio option:

	$bulk_form->addField('weekday', ['Radio'], ['values'=> STD_GERMAN_WEEKDAYS, 'caption' => 'Wöchentlich am']);
	
	$bulk_form->onSubmit(function() use($wizard, $bulk_form) {
		//no value selected? error
		if(!$bulk_form->model->get('weekday')) {
			return $bulk_form->error('weekday', 'Bitte wähle einen Wochentag aus');
		}	

radioerrormessage

The false positioning of the error messages may well be due to some of my CSS changes, but IMHO displaying the error message on every single radio item seems wrong.

Proposal: Make all radio items red, display the error message on first one only

checkboxes are also affected - see #1826

@ibelar
Copy link
Contributor

ibelar commented May 1, 2018

This is not really related to atk4 but more on semantic-ui.

The only way to remove label for each individual radio button is to use the form setting inline set to false.

You could override Form class and render it like:

$this->js(true)
            ->api(['url' => $cb->getJSURL(),  'method' => 'POST', 'serializeForm' => true])
            ->form(['inline' => false, 'on' => 'blur']);

Now using

return $bulk_form->error('weekday', 'Bitte wähle einen Wochentag aus');

Will display all radio in red with no label.
However, this will also remove label for all fields in form.

If you would still like to send error message to user you can add an error view inside your form:

$error = $f->add('View')->addClass('ui error message');

and display your error message at ounce using:

$bulk_form->onSubmit(function() use($wizard, $bulk_form) {
    // on error 
   return $bulk_form->js()->form('add errors', ['error_1', error_2']);
}

Hope this help.

@PhilippGrashoff
Copy link
Collaborator Author

Hi Alain,

thx for the explanation. So I will add this to the Semantic UI issues as this will be the correct place then.

@romaninsh
Copy link
Member

if you do - reference this ticket here..

@mvorisek mvorisek reopened this Oct 28, 2020
@mvorisek mvorisek changed the title FormField Radio: Error Message is displayed at every radio option Radio error prompt is displayed at every option Jun 17, 2023
@mvorisek
Copy link
Member

It seems there is no SUI/FUI issue, the closest (but different) issues I found is fomantic/Fomantic-UI#1387.

@mvorisek mvorisek changed the title Radio error prompt is displayed at every option Radio/checkbox error prompt is displayed at every option Nov 24, 2024
@mvorisek mvorisek removed the JS label Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants