Beate Posted February 6, 2014 Posted February 6, 2014 Hello, I'm using the API to generete a form. Is it possible to display sth other than the label name in the header (in my case "Newsletter") of a checkbox? This is my code: $field = $modules->get("InputfieldCheckbox"); $field->label = "Ja, ich möchte per E-Mail über Neuheiten informiert werden."; $field->attr('title','Newsletter'); $field->attr('id+name','newsletter'); $field->required = 0; $form->append($field); I tried title but it didn't work. I also looked in the source, but it seems it is not possible? I can't beleave that I'm the first one with this problem, but a search wasn't succesful Thanks, beate
Martijn Geerts Posted February 6, 2014 Posted February 6, 2014 This is posted on gitHub, there are more votes to change this behaviour. We'll have to wait what the respond is.
Beate Posted February 6, 2014 Author Posted February 6, 2014 Ok, thanks. Is there some kind of workaround? This behavior is not so nice.... Ticket in github
Wanze Posted February 6, 2014 Posted February 6, 2014 There is a workaround, but it changes the value that is sent: $field->checkedValue = 'Yes'; Displays 'yes' as label 3
Soma Posted February 6, 2014 Posted February 6, 2014 U I often use $field = $modules->get("InputfieldMarkup"); $field->value = "<label><input type='checkbox' name='newsletter'>Ja, ich möchte per E-Mail über Neuheiten informiert werden</label>"; $form->append($field); Also you could use InputfieldCheckboxes and use addOptions(key, value) so you can set to not display header, but it will make the checkbox name an array $field = $modules->get("InputfieldCheckboxes"); $field->skipLabel = Inputfield::skipLabelHeader; $field->addOption("newsletter", "Ja, ich möchte per E-Mail über Neuheiten informiert werden"); $form->append($field); 3
Beate Posted February 6, 2014 Author Posted February 6, 2014 $field->skipLabel = Inputfield::skipLabelHeader; This is nice, i think i'll stay with this
ryan Posted February 8, 2014 Posted February 8, 2014 If using the latest version of PW with the new default admin theme, it doesn't display the Inputfield label if there is no description – just shows the checkbox label. From the API side, you can also specify $field->label2 as something distinct from $field->label, where $field->label2 is the second label (the one for the checkbox). 2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now