Welcome,
Guest
.
Please
login
or
register
.
Did you miss your
activation email
?
News:
Download Elxis CMS:
Elxis 5.5 Hermes
.
Home
Help
Login
Register
Elxis CMS Forum
»
Support
»
Elxis 4.x/5.x DEV
»
Elxis 5.1 - Combined form elements
« previous
next »
Print
Pages: [
1
]
Author
Topic: Elxis 5.1 - Combined form elements (Read 2796 times)
datahell
Elxis Team
Hero Member
Posts: 10356
Elxis 5.1 - Combined form elements
«
on:
February 02, 2020, 20:37:42 »
Elxis 5 form library (
elxis5Form
) since
Elxis 5.1
supports grouping of multiple form elements into one. For instance, 2 input form elements on the same line with a single label.
I will write an example below to better understand the new feature, I am sure you will find it VERY useful.
The general idea
Generate the elements we want one by one without a wrapping div, without label and without displaying them. We save the generated html into the buffer and we display them later with a single
label
and optionally
tip
.
Full example
First we command the elxis5Form library not to display the generated elements by return the html instead:
$form->setOption('returnhtml', true);
Now we generate a
Select
form element. We define the "
onlyelement
" attribute and we set its value to
1
. This will tell the elxis5Library not to include the wrapping div and label in returned html. Note that the label text has no important as it will not be displayed. We save the returned html in variable
$chtml
:
$options = array();
$options[] = $form->makeOption('mr', 'Mr.');
$options[] = $form->makeOption('ms', 'Ms.');
$chtml = $form->addSelect('gendre', 'Gendre', 'mr', $options, array('onlyelement' => 1, 'class' => 'elx5_select elx5_inselect'));
Now we generate an input form element the same way and add generated html into $chtml variable:
$chtml .= $form->addText('firstname', '', 'Firstname', array('onlyelement' => 1, 'class' => 'elx5_text elx5_mediumtext'));
And an other one:
$chtml .= $form->addText('lastname', '', 'Lastname', array('onlyelement' => 1, 'class' => 'elx5_text elx5_mediumtext'));
Job done, return "
returnhtml
" option back to
false
:
$form->setOption('returnhtml', false);
Now we display the combination of the 3 above form elements by using the
addCombined
method:
$form->addCombined('firstname', 'Your name', $chtml);
I attach a screenshot were you can see the actual result.
«
Last Edit: February 02, 2020, 20:52:32 by datahell
»
Logged
Elxis Team
|
Is Open Source
|
IOS Rentals | IOS AERO
michalis1984
Sr. Member
Posts: 334
Re: Elxis 5.1 - Combined form elements
«
Reply #1 on:
February 02, 2020, 23:11:59 »
Interesting and useful. Need to refresh and update the knowledge of the form library
Logged
Print
Pages: [
1
]
« previous
next »
Elxis CMS Forum
»
Support
»
Elxis 4.x/5.x DEV
»
Elxis 5.1 - Combined form elements