Last active
December 16, 2015 20:19
-
-
Save ringmaster/5491373 to your computer and use it in GitHub Desktop.
Alter the login form.
This file contains hidden or 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
<?php | |
public function action_modify_form_habari_login(FormUI $form) { | |
// Remove the reset message | |
$form->remove($form->reset_message); | |
// Create a ul wrapper that wraps its children in li's | |
$buttons = $form->append(FormControlWrapper::create('buttons')->set_setting('wrap_element', 'ul')->set_setting('wrap_each', '<li>%s</li>')); | |
// Move the login button from the dropbutton to the button wrapper we just created | |
$form->move_into($form->login, $buttons); | |
// Remove the dropbutton | |
$form->remove($form->submit_button); | |
// Add a Register button | |
$buttons->append(FormControlSubmit::create('register')->set_caption('Register?')->on_success(function(){ })); | |
// Move the reset button into the button wrapper we created | |
$form->move_into($form->reset_button, $buttons); | |
// Remove the javascript links | |
$form->remove($form->reset_link); | |
$form->remove($form->login_link); | |
// Insert a fieldset before the label for the username field | |
$form->insert($form->label_for_habari_username, $inputs = FormControlFieldset::create('inputs')); | |
// Move the username label (and the input control inside it) into the created fieldset | |
$form->move_into($form->label_for_habari_username, $inputs); | |
// Move the password label (and the input control inside it) into the created fieldset | |
$form->move_into($form->label_for_habari_password, $inputs); | |
// Add "foo" as a class to all of the buttons in the buttons wrapper | |
$buttons->each(function(FormControl $control){ | |
$control->add_class('foo'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment