Skip to content

Instantly share code, notes, and snippets.

@emeraldjava
Created August 7, 2013 16:14
Show Gist options
  • Save emeraldjava/6175555 to your computer and use it in GitHub Desktop.
Save emeraldjava/6175555 to your computer and use it in GitHub Desktop.
WP-Form Decorator Gist
$firstname = WP_Form_Element::create('text')->set_name('first-name')->set_label('First Name');
$firstname->set_view(new WP_Form_View_Input());
$firstname->add_decorator('WP_Form_Decorator_Label', array());
$firstname->add_decorator('WP_Form_Decorator_Description', array());
$firstname->add_decorator('WP_Form_Decorator_HtmlTag', array('tag' => 'div', 'attributes' => array( 'class' => 'control-group' )));
$lastname = WP_Form_Element::create('text')->set_name('last-name')->set_label('Last Name');
$lastname->set_view(new WP_Form_View_Input());
$lastname->add_decorator('WP_Form_Decorator_Label', array('position' => WP_Form_Decorator::POSITION_BEFORE));
$lastname->add_decorator('WP_Form_Decorator_Description', array());
$lastname->add_decorator('WP_Form_Decorator_HtmlTag', array('tag' => 'div', 'attributes' => array( 'class' => 'control-group' )));
$submit = WP_Form_Element::create('submit')
->set_name('submit')
->set_label('WP-FORM');
$form->add_element($firstname);
$form->add_element($lastname);
$form->add_element($submit);
$form->add_class('form-example');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment