本文整理汇总了PHP中FormAction::addExtraClass方法的典型用法代码示例。如果您正苦于以下问题:PHP FormAction::addExtraClass方法的具体用法?PHP FormAction::addExtraClass怎么用?PHP FormAction::addExtraClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormAction
的用法示例。
在下文中一共展示了FormAction::addExtraClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
{
if (!$fields) {
$helpHtml = _t('GroupImportForm.Help1', '<p>Import one or more groups in <em>CSV</em> format (comma-separated values).' . ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>');
$helpHtml .= _t('GroupImportForm.Help2', '<div class="advanced">
<h4>Advanced usage</h4>
<ul>
<li>Allowed columns: <em>%s</em></li>
<li>Existing groups are matched by their unique <em>Code</em> value, and updated with any new values from the
imported file</li>
<li>Group hierarchies can be created by using a <em>ParentCode</em> column.</li>
<li>Permission codes can be assigned by the <em>PermissionCode</em> column. Existing permission codes are not
cleared.</li>
</ul>
</div>');
$importer = new GroupCsvBulkLoader();
$importSpec = $importer->getImportSpec();
$helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
$fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('CsvFile', _t('SecurityAdmin_MemberImportForm.FileFieldLabel', 'CSV File <small>(Allowed extensions: *.csv)</small>')));
$fileField->getValidator()->setAllowedExtensions(array('csv'));
}
if (!$actions) {
$action = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'));
$action->addExtraClass('ss-ui-button');
$actions = new FieldList($action);
}
if (!$validator) {
$validator = new RequiredFields('CsvFile');
}
parent::__construct($controller, $name, $fields, $actions, $validator);
$this->addExtraClass('cms');
$this->addExtraClass('import-form');
}
示例2: EditProfileForm
/**
* @return Form|SS_HTTPResponse
*/
public function EditProfileForm()
{
if (!Member::currentUser()) {
$this->setFlash(_t('EditProfilePage.LoginWarning', 'Please login to edit your profile'), 'warning');
return $this->redirect(Director::absoluteBaseURL());
}
$firstName = new TextField('FirstName');
$firstName->setAttribute('placeholder', _t('EditProfilePage.FirstNamePlaceholder', 'Enter your first name'))->setAttribute('required', 'required')->addExtraClass('form-control');
$surname = new TextField('Surname');
$surname->setAttribute('placeholder', _t('EditProfilePage.SurnamePlaceholder', 'Enter your surname'))->setAttribute('required', 'required')->addExtraClass('form-control');
$email = new EmailField('Email');
$email->setAttribute('placeholder', _t('EditProfilePage.EmailPlaceholder', 'Enter your email address'))->setAttribute('required', 'required')->addExtraClass('form-control');
$jobTitle = new TextField('JobTitle');
$jobTitle->setAttribute('placeholder', _t('EditProfilePage.JobTitlePlaceholder', 'Enter your job title'))->addExtraClass('form-control');
$website = new TextField('Website');
$website->setAttribute('placeholder', _t('EditProfilePage.WebsitePlaceholder', 'Enter your website'))->addExtraClass('form-control');
$blurb = new TextareaField('Blurb');
$blurb->setAttribute('placeholder', _t('EditProfilePage.BlurbPlaceholder', 'Enter your blurb'))->addExtraClass('form-control');
$confirmPassword = new ConfirmedPasswordField('Password', _t('EditProfilePage.PasswordLabel', 'New Password'));
$confirmPassword->canBeEmpty = true;
$confirmPassword->setAttribute('placeholder', _t('EditProfilePage.PasswordPlaceholder', 'Enter your password'))->addExtraClass('form-control');
$fields = new FieldList($firstName, $surname, $email, $jobTitle, $website, $blurb, $confirmPassword);
$action = new FormAction('SaveProfile', _t('EditProfilePage.SaveProfileText', 'Update Profile'));
$action->addExtraClass('btn btn-primary btn-lg');
$actions = new FieldList($action);
// Create action
$validator = new RequiredFields('FirstName', 'Email');
//Create form
$form = new Form($this, 'EditProfileForm', $fields, $actions, $validator);
//Populate the form with the current members data
$Member = Member::currentUser();
$form->loadDataFrom($Member->data());
//Return the form
return $form;
}
示例3: FieldList
function __construct($controller, $name)
{
$fields = new FieldList(array($t1 = new TextField('ExternalOrderId', 'Eventbrite Order #'), $checkbox = new CheckboxField('SharedContactInfo', 'Allow to share contact info?')));
$t1->setAttribute('placeholder', 'Enter your Eventbrite order #');
$t1->addExtraClass('event-brite-order-number');
$attendees = Session::get('attendees');
if (count($attendees) > 0) {
$t1->setValue(Session::get('ExternalOrderId'));
$t1->setReadonly(true);
$checkbox->setValue(intval(Session::get('SharedContactInfo')) === 1);
$fields->add(new LiteralField('ctrl1', 'Current Order has following registered attendees, please select one:'));
$options = array();
foreach ($attendees as $attendee) {
$ticket_external_id = intval($attendee['ticket_class_id']);
$ticket_type = SummitTicketType::get()->filter('ExternalId', $ticket_external_id)->first();
if (is_null($ticket_type)) {
continue;
}
$options[$attendee['id']] = $attendee['profile']['name'] . ' (' . $ticket_type->Name . ')';
}
$attendees_ctrl = new OptionSetField('SelectedAttendee', '', $options);
$fields->add($attendees_ctrl);
$validator = new RequiredFields(array('ExternalOrderId'));
// Create action
$actions = new FieldList($btn_clear = new FormAction('clearSummitAttendeeInfo', 'Clear'), $btn = new FormAction('saveSummitAttendeeInfo', 'Done'));
$btn->addExtraClass('btn btn-default active');
$btn_clear->addExtraClass('btn btn-danger active');
} else {
$validator = new RequiredFields(array('ExternalOrderId'));
// Create action
$actions = new FieldList($btn = new FormAction('saveSummitAttendeeInfo', 'Get Order'));
$btn->addExtraClass('btn btn-default active');
}
parent::__construct($controller, $name, $fields, $actions, $validator);
}
示例4: __construct
public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
{
if (!$fields) {
$helpHtml = _t('MemberImportForm.Help1', '<p>Import users in <em>CSV format</em> (comma-separated values).' . ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>');
$helpHtml .= _t('MemberImportForm.Help2', '<div class="advanced">' . '<h4>Advanced usage</h4>' . '<ul>' . '<li>Allowed columns: <em>%s</em></li>' . '<li>Existing users are matched by their unique <em>Code</em> property, and updated with any new values from ' . 'the imported file.</li>' . '<li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, ' . 'multiple groups can be separated by comma. Existing group memberships are not cleared.</li>' . '</ul>' . '</div>');
$importer = new MemberCsvBulkLoader();
$importSpec = $importer->getImportSpec();
$helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
$fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('CsvFile', _t('SecurityAdmin_MemberImportForm.FileFieldLabel', 'CSV File <small>(Allowed extensions: *.csv)</small>')));
$fileField->getValidator()->setAllowedExtensions(array('csv'));
}
if (!$actions) {
$action = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'));
$action->addExtraClass('ss-ui-button');
$actions = new FieldList($action);
}
if (!$validator) {
$validator = new RequiredFields('CsvFile');
}
parent::__construct($controller, $name, $fields, $actions, $validator);
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/javascript/MemberImportForm.js');
$this->addExtraClass('cms');
$this->addExtraClass('import-form');
}
示例5: TextField
function __construct($controller, $name)
{
$SearchField = new TextField('Search', 'Search');
$fields = new FieldList($SearchField);
$searchButton = new FormAction('doSearch', 'Search');
$searchButton->addExtraClass('button');
$actions = new FieldList($searchButton);
parent::__construct($controller, $name, $fields, $actions);
}
示例6: TextareaField
function __construct($controller, $name)
{
$FeedbackField = new TextareaField('Content', 'My Feedback About This Page');
$fields = new FieldList($FeedbackField);
$tellUsButton = new FormAction('submitFeedback', 'Tell Us');
$tellUsButton->addExtraClass('button');
$actions = new FieldList($tellUsButton);
parent::__construct($controller, $name, $fields, $actions);
}
示例7: FieldSet
function __construct($controller, $name, $fields, $validator, $readonly, $dataObject) {
$this->dataObject = $dataObject;
/**
* WARNING: DO NOT CHANGE THE ORDER OF THESE JS FILES
* Some have special requirements.
*/
//Requirements::css(CMS_DIR . 'css/layout.css');
Requirements::css(SAPPHIRE_DIR . '/css/Form.css');
Requirements::css(SAPPHIRE_DIR . '/css/ComplexTableField_popup.css');
Requirements::css(CMS_DIR . '/css/typography.css');
Requirements::css(CMS_DIR . '/css/cms_right.css');
Requirements::css(THIRDPARTY_DIR . '/jquery/plugins/autocomplete/jquery.ui.autocomplete.css');
Requirements::javascript(THIRDPARTY_DIR . "/prototype.js");
Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js");
Requirements::javascript(THIRDPARTY_DIR . "/prototype_improvements.js");
Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/scriptaculous.js");
Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/controls.js");
Requirements::javascript(THIRDPARTY_DIR . "/layout_helpers.js");
Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain.js");
Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain_right.js");
Requirements::javascript(SAPPHIRE_DIR . "/javascript/TableField.js");
Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField.js");
Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField_popup.js");
// jQuery requirements (how many of these are actually needed?)
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery_improvements.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/livequery/jquery.livequery.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery/ui/ui.core.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery/ui/ui.tabs.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/form/jquery.form.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/dimensions/jquery.dimensions.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/autocomplete/jquery.ui.autocomplete.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/ScaffoldComplexTableField.js');
Requirements::javascript(CMS_DIR . '/javascript/ModelAdmin.js');
if($this->dataObject->hasMethod('getRequirementsForPopup')) {
$this->dataObject->getRequirementsForPopup();
}
$actions = new FieldSet();
if(!$readonly) {
$actions->push(
$saveAction = new FormAction("saveComplexTableField", "Save")
);
$saveAction->addExtraClass('save');
}
$fields->push(new HiddenField("ComplexTableField_Path", Director::absoluteBaseURL()));
parent::__construct($controller, $name, $fields, $actions, $validator);
}
示例8: ContactForm
function ContactForm()
{
// Create fields
$fields = new FieldList(TextField::create('Name')->setTitle(_t('ContactPage.NAMEINPUT', "Name <em>*</em>")), TextField::create("Cellphone")->setTitle(_t('ContactPage.CELLPHONE', "Cellphone")), EmailField::create("Email")->setTitle(_t('ContactPage.EMAIL', "Email address"))->setAttribute('type', 'email'), TextareaField::create("Question")->setTitle(_t('ContactPage.QUESTION', "Question <em>*</em>")));
$this->extend('updateContactForm', $fields);
// Create action
$send = new FormAction('SendContactForm', _t('ContactPage.SEND', "Send"));
$send->addExtraClass("success btn");
$actions = new FieldList($send);
// Create action
$validator = new RequiredFields('Name', 'Email', 'Question');
return new Form($this, 'ContactForm', $fields, $actions, $validator);
}
示例9: getCMSActions
public function getCMSActions()
{
$actions = parent::getCMSActions();
$addCreditCard = new FormAction('addCreditCard', 'Add Credit Card');
$addCreditCard->addExtraClass('ss-ui-action-constructive');
$updateCreditCard = new FormAction('updateCreditCard', 'Update Credit Card');
$updateCreditCard->addExtraClass('ss-ui-action-constructive');
if ($this->ID) {
$actions->push($updateCreditCard);
}
if (!$this->ID) {
$actions->push($addCreditCard);
}
return $actions;
}
示例10: getCMSActions
public function getCMSActions()
{
$actions = parent::getCMSActions();
$createSubscription = new FormAction('createSubscription', 'Create Subscription');
$createSubscription->addExtraClass('ss-ui-action-constructive');
$cancelSubscription = new FormAction('cancelSubscription', 'Cancel Subscription');
$cancelSubscription->addExtraClass('ss-ui-action-destructive');
$changeSubscription = new FormAction('changeSubscription', 'Change Subscription');
$changeSubscription->addExtraClass('ss-ui-action-constructive');
if ($this->ID && $this->Status && ($this->ProductID == 1 || $this->ProductID == 2 || $this->ProductID == 3)) {
$actions->push($cancelSubscription);
$actions->push($changeSubscription);
}
if (!$this->ID) {
$actions->push($createSubscription);
}
return $actions;
}
示例11: OrderForm
public function OrderForm($id = null)
{
$product = empty($id) ? new Product() : DataObject::get_one('Product', array('ID' => (int) $id));
try {
$processor = PaymentFactory::factory($this->paymentMethod);
} catch (Exception $e) {
$fields = new FieldList(array(new ReadonlyField($e->getMessage())));
$actions = new FieldList();
return new Form($this, 'OrderForm', $fields, $actions);
}
$fields = new FieldList();
$fields->push(new HiddenField('Amount', 'Amount', $product->Price));
$fields->push(new HiddenField('Currency', 'Currency', 'NZD'));
$fields->push(new HiddenField('PaymentMethod', 'PaymentMethod', 'PayPalExpress'));
$actions = new FieldList($button = new FormAction('processOrder', 'Buy Now'));
$button->addExtraClass('button expand');
$validator = $processor->getFormRequirements();
$form = new Form($this, "OrderForm", $fields, $actions, $validator);
$form->setTemplate('OrderForm');
return $form;
}
示例12: RegistrationForm
/**
* @return static
*/
function RegistrationForm()
{
// Email
$email = new EmailField('Email');
$email->setAttribute('placeholder', _t('RegistrationPage.EmailPlaceholder', 'Enter your email address'))->setAttribute('required', 'required')->addExtraClass('form-control');
// Password Conformation
$password = new PasswordField('Password');
$password->setAttribute('placeholder', _t('RegistrationPage.PasswordPlaceholder', 'Enter your password'))->setCustomValidationMessage(_t('RegistrationPage.PasswordValidationText', 'Your passwords do not match'), 'validation')->setAttribute('required', 'required')->addExtraClass('form-control');
// Generate the fields
$fields = new FieldList($email, $password);
// Submit Button
$action = new FormAction('Register', 'Register');
$action->addExtraClass('btn btn-primary btn-lg');
$actions = new FieldList($action);
$validator = new RequiredFields('Email', 'Password');
$form = Form::create($this, 'RegistrationForm', $fields, $actions, $validator);
if ($formData = Session::get('FormInfo.Form_RegistrationForm.data')) {
$form->loadDataFrom($formData);
}
return $form;
}
示例13: FieldList
function __construct($controller, $name)
{
$f = new FieldList();
$f->push(BootstrapTextField::create('Name', "Full name"));
$f->push(BootstrapEmailField::create('Email', "Email (will not be published)"));
$f->push(BootstrapEmailField::create('ContactNumber', 'Contact number (will not be published)'));
$f->push(CustomCountryDropdownField::create('Country')->setEmptyString('--please select--'));
$f->push(BootstrapTextField::create('Town'));
$f->push(BootstrapTextField::create('Latitude'));
$f->push(BootstrapTextField::create('Longitude'));
$f->push(FileField::create('Image'));
$f->push(BootstrapTextareaField::create('Description')->setRightTitle("<div id='charLeft'><span>200</span></div>"));
$actions = new FieldList($btn = new FormAction('doSubmit', 'Submit'));
$btn->addExtraClass("btn");
$aRequiredFields = array();
$aRequiredFields[] = "Name";
$aRequiredFields[] = "Email";
$aRequiredFields[] = "Description";
$requiredFields = new RequiredFields();
parent::__construct($controller, $name, $f, $actions, $requiredFields);
$this->addExtraClass('form-horizontal ' . get_class());
//$this->loadValidationScripts($this, $aRequiredFields);
}
示例14: build
/**
* @param ISurveyStep $step
* @param string $action
* @param string $form_name
* @return Form
*/
public function build(ISurveyStep $step, $action, $form_name = 'SurveyStepForm')
{
$form = parent::build($step, $action, $form_name);
$entity_survey = $step->survey();
if ($entity_survey instanceof IEntitySurvey) {
$fields = $form->Fields();
$first = $fields->first();
if ($entity_survey->isTeamEditionAllowed() && $entity_survey->createdBy()->getIdentifier() === Member::currentUserID() && $entity_survey->isFirstStep()) {
$fields->insertBefore($team_field = new EntitySurveyEditorTeamField('EditorTeam', '', $entity_survey), $first->getName());
$team_field->setForm($form);
$first = $team_field;
}
$edition_info_panel = '<div class="container editor-info-panel"><div class="row">Created by <b>' . $entity_survey->createdBy()->getEmail() . '</b></div>';
$edition_info_panel .= '<div class="row">Edited by <b>' . $entity_survey->EditedBy()->getEmail() . '</b></div></div>';
$fields->insertBefore(new LiteralField('owner_label', $edition_info_panel), $first->getName());
$previous_step = $entity_survey->getPreviousStep($step->template()->title());
if (!is_null($previous_step)) {
$request = Controller::curr()->getRequest();
$step = $request->param('STEP_SLUG');
if (empty($step)) {
$step = $request->requestVar('STEP_SLUG');
}
if (empty($step)) {
throw new LogicException('step empty! - member_id %s', Member::currentUserID());
}
$entity_survey_id = intval($request->param('ENTITY_SURVEY_ID'));
$prev_step_url = Controller::join_links(Director::absoluteBaseURL(), Controller::curr()->Link(), $step, 'edit', $entity_survey_id, $previous_step->template()->title());
// add prev button
$actions = $form->Actions();
$btn = $actions->offsetGet(0);
$actions->insertBefore($prev_action = new FormAction('PrevStep', 'Prev Step'), $btn->name);
$prev_action->addExtraClass('entity-survey-prev-action');
$prev_action->setAttribute('data-prev-url', $prev_step_url);
}
}
return $form;
}
示例15: __construct
public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
{
if (!$fields) {
$helpHtml = _t('ExcelMemberImportForm.Help1', '<p><a href="{link}">Download sample file</a></p>', array('link' => $controller->Link('downloadsample/Member')));
$helpHtml .= _t('ExcelMemberImportForm.Help2', '<ul>' . '<li>Existing users are matched by their unique <em>Email</em> property, and updated with any new values from ' . 'the imported file.</li>' . '<li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, ' . 'multiple groups can be separated by comma. Existing group memberships are not cleared.</li>' . '</ul>');
$importer = new MemberCsvBulkLoader();
$importSpec = $importer->getImportSpec();
$helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
$extensions = array('csv', 'xls', 'xlsx', 'ods', 'txt');
$fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('File', _t('ExcelMemberImportForm.FileFieldLabel', 'File <small><br/>(allowed extensions: {extensions})</small>', array('extensions' => implode(', ', $extensions)))));
$fileField->getValidator()->setAllowedExtensions(ExcelImportExport::getValidExtensions());
}
if (!$actions) {
$action = new FormAction('doImport', _t('ExcelMemberImportForm.BtnImport', 'Import from file'));
$action->addExtraClass('ss-ui-button');
$actions = new FieldList($action);
}
if (!$validator) {
$validator = new RequiredFields('File');
}
parent::__construct($controller, $name, $fields, $actions, $validator);
$this->addExtraClass('cms');
$this->addExtraClass('import-form');
}