How to remove form elements

Bill Lions
Member | 47
+
0
-

I have a user form with the obligatory password, and passwordVerify fields.
However, when editing the user, I do not want these fields displayed, or processed.

{control userForm}

How best to to remove form fields, or is best practice to manually render the form elements?

{form userForm}
{label username} {input username /}
{label age} {input age /}

{/form}

Or is there a better/other way?

David Matějka
Moderator | 6445
+
0
-

Hi, you can remove a form element using unset($form['password']). But it is better to pass some parameter to a form factory, so the field is not created in the first place.

Pavel Kravčík
Member | 1180
+
0
-
//pseudocode

$form = new Form;

if($something)
{
	$form->addTextInput()
}