Created
August 7, 2013 16:14
-
-
Save emeraldjava/6175555 to your computer and use it in GitHub Desktop.
WP-Form Decorator Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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