本文整理汇总了PHP中FormAction::create方法的典型用法代码示例。如果您正苦于以下问题:PHP FormAction::create方法的具体用法?PHP FormAction::create怎么用?PHP FormAction::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormAction
的用法示例。
在下文中一共展示了FormAction::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Returns an instance of this class
*
* @param Controller $controller
* @param string $name
*/
public function __construct($controller, $name)
{
$fields = new FieldList(array(new HiddenField('AuthenticationMethod', null, $this->authenticator_class)));
$actions = new FieldList(array(FormAction::create('redirectToRealMe', _t('RealMeLoginForm.LOGINBUTTON', 'LoginAction'))->setUseButtonTag(true)->setButtonContent('<span class="realme_button_padding">Login or register with RealMe<span class="realme_icon_new_window"></span> <span class="realme_icon_padlock"></span>')->setAttribute('class', 'realme_button')));
// Taken from MemberLoginForm
if (isset($_REQUEST['BackURL'])) {
$backURL = $_REQUEST['BackURL'];
} elseif (Session::get('BackURL')) {
$backURL = Session::get('BackURL');
}
if (isset($backURL)) {
// Ensure that $backURL isn't redirecting us back to login form or a RealMe authentication page
if (strpos($backURL, 'Security/login') === false && strpos($backURL, 'Security/realme') === false) {
$fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
}
}
// optionally include requirements {@see /realme/_config/config.yml}
if ($this->config()->include_jquery) {
Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js");
}
if ($this->config()->include_javascript) {
Requirements::javascript(REALME_MODULE_PATH . "/javascript/realme.js");
}
if ($this->config()->include_css) {
Requirements::css(REALME_MODULE_PATH . "/css/realme.css");
}
parent::__construct($controller, $name, $fields, $actions);
}
示例2: __construct
public function __construct($controller, $name = "CreateOrganisationForm")
{
$fields = $this->getOrganisationFields();
$actions = new FieldList(FormAction::create("docreate", "Create"));
$validator = new OrganisationFormValidator('Name');
parent::__construct($controller, $name, $fields, $actions, $validator);
}
开发者ID:helpfulrobot,项目名称:burnbright-silverstripe-organisations,代码行数:7,代码来源:CreateOrganisationForm.php
示例3: __construct
/**
* @param Controller $controller
* @param String $name
* @param array $arguments
*/
public function __construct($controller, $name, $arguments = array())
{
/** =========================================
* @var EmailField $emailField
* @var TextField $nameField
* @var FormAction $submit
* @var Form $form
===========================================*/
/** -----------------------------------------
* Fields
* ----------------------------------------*/
$emailField = EmailField::create('Email', 'Email Address');
$emailField->addExtraClass('form-control')->setAttribute('placeholder', 'Email')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Email</strong>')->setCustomValidationMessage('Please enter your <strong>Email</strong>');
$nameField = TextField::create('Name', 'Name');
$nameField->setAttribute('placeholder', 'Name')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Name</strong>')->setCustomValidationMessage('Please enter your <strong>Name</strong>');
$fields = FieldList::create($nameField, $emailField);
/** -----------------------------------------
* Actions
* ----------------------------------------*/
$submit = FormAction::create('Subscribe');
$submit->setTitle('SIGN UP')->addExtraClass('button');
$actions = FieldList::create($submit);
/** -----------------------------------------
* Validation
* ----------------------------------------*/
$required = RequiredFields::create('Name', 'Email');
$form = Form::create($this, $name, $fields, $actions, $required);
if ($formData = Session::get('FormInfo.Form_' . $name . '.data')) {
$form->loadDataFrom($formData);
}
parent::__construct($controller, $name, $fields, $actions, $required);
$this->setAttribute('data-parsley-validate', true);
$this->addExtraClass('form');
}
示例4: ShortcodeForm
/**
* Provides a GUI for the insert/edit shortcode popup
* @return Form
**/
public function ShortcodeForm()
{
if (!Permission::check('CMS_ACCESS_CMSMain')) {
return;
}
Config::inst()->update('SSViewer', 'theme_enabled', false);
// create a list of shortcodable classes for the ShortcodeType dropdown
$classList = ClassInfo::implementorsOf('Shortcodable');
$classes = array();
foreach ($classList as $class) {
$classes[$class] = singleton($class)->singular_name();
}
// load from the currently selected ShortcodeType or Shortcode data
$classname = false;
$shortcodeData = false;
if ($shortcode = $this->request->requestVar('Shortcode')) {
$shortcode = str_replace("", '', $shortcode);
//remove BOM inside string on cursor position...
$shortcodeData = singleton('ShortcodableParser')->the_shortcodes(array(), $shortcode);
if (isset($shortcodeData[0])) {
$shortcodeData = $shortcodeData[0];
$classname = $shortcodeData['name'];
}
} else {
$classname = $this->request->requestVar('ShortcodeType');
}
if ($shortcodeData) {
$headingText = _t('Shortcodable.EDITSHORTCODE', 'Edit Shortcode');
} else {
$headingText = _t('Shortcodable.INSERTSHORTCODE', 'Insert Shortcode');
}
// essential fields
$fields = FieldList::create(array(CompositeField::create(LiteralField::create('Heading', sprintf('<h3 class="htmleditorfield-shortcodeform-heading insert">%s</h3>', $headingText)))->addExtraClass('CompositeField composite cms-content-header nolabel'), LiteralField::create('shortcodablefields', '<div class="ss-shortcodable content">'), DropdownField::create('ShortcodeType', 'ShortcodeType', $classes, $classname)->setHasEmptyDefault(true)->addExtraClass('shortcode-type')));
// attribute and object id fields
if ($classname) {
if (class_exists($classname)) {
$class = singleton($classname);
if (is_subclass_of($class, 'DataObject')) {
if (singleton($classname)->hasMethod('get_shortcodable_records')) {
$dataObjectSource = $classname::get_shortcodable_records();
} else {
$dataObjectSource = $classname::get()->map()->toArray();
}
$fields->push(DropdownField::create('id', $class->singular_name(), $dataObjectSource)->setHasEmptyDefault(true));
}
if ($attrFields = $classname::shortcode_attribute_fields()) {
$fields->push(CompositeField::create($attrFields)->addExtraClass('attributes-composite'));
}
}
}
// actions
$actions = FieldList::create(array(FormAction::create('insert', _t('Shortcodable.BUTTONINSERTSHORTCODE', 'Insert shortcode'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true)));
// form
$form = Form::create($this, "ShortcodeForm", $fields, $actions)->loadDataFrom($this)->addExtraClass('htmleditorfield-form htmleditorfield-shortcodable cms-dialog-content');
if ($shortcodeData) {
$form->loadDataFrom($shortcodeData['atts']);
}
$this->extend('updateShortcodeForm', $form);
return $form;
}
开发者ID:helpfulrobot,项目名称:sheadawson-silverstripe-shortcodable,代码行数:64,代码来源:ShortcodableController.php
示例5: AddNewListboxForm
public function AddNewListboxForm()
{
$action = FormAction::create('doSave', 'Save')->setUseButtonTag('true');
if (!$this->isFrontend) {
$action->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept');
}
$model = $this->getModel();
$link = singleton($model);
$fields = $link->getCMSFields();
$title = $this->getDialogTitle() ? $this->getDialogTitle() : 'New Item';
$fields->insertBefore(HeaderField::create('AddNewHeader', $title), $fields->first()->getName());
$actions = FieldList::create($action);
$form = Form::create($this, 'AddNewListboxForm', $fields, $actions);
$fields->push(HiddenField::create('model', 'model', $model));
/*
if($link){
$form->loadDataFrom($link);
$fields->push(HiddenField::create('LinkID', 'LinkID', $link->ID));
}
// Chris Bolt, fixed this
//$this->owner->extend('updateLinkForm', $form);
$this->extend('updateLinkForm', $form);
// End Chris Bolt
*/
return $form;
}
示例6: FrontEndPostForm
/**
* A simple form for creating blog entries
*/
function FrontEndPostForm()
{
if ($this->owner->request->latestParam('ID')) {
$id = (int) $this->owner->request->latestParam('ID');
} else {
$id = 0;
}
$membername = Member::currentUser() ? Member::currentUser()->getName() : "";
// Set image upload
$uploadfield = UploadField::create('FeaturedImage', _t('BlogFrontEnd.ShareImage', "Share an image"));
$uploadfield->setCanAttachExisting(false);
$uploadfield->setCanPreviewFolder(false);
$uploadfield->setAllowedFileCategories('image');
$uploadfield->relationAutoSetting = false;
if (BlogFrontEnd::config()->allow_wysiwyg_editing) {
$content_field = TrumbowygHTMLEditorField::create("Content", _t("BlogFrontEnd.Content"));
} else {
$content_field = TextareaField::create("Content", _t("BlogFrontEnd.Content"));
}
$form = new Form($this->owner, 'FrontEndPostForm', $fields = new FieldList(HiddenField::create("ID", "ID"), TextField::create("Title", _t('BlogFrontEnd.Title', "Title")), $uploadfield, $content_field), $actions = new FieldList(FormAction::create('doSavePost', _t('BlogFrontEnd.PostEntry', 'Post Entry'))), new RequiredFields('Title'));
$uploadfield->setForm($form);
if ($this->owner->Categories()->exists()) {
$fields->add(CheckboxsetField::create("Categories", _t("BlogFrontEnd.PostUnderCategories", "Post this in a category? (optional)"), $this->owner->Categories()->map()));
}
if ($this->owner->Tags()->exists()) {
$fields->add(CheckboxsetField::create("Categories", _t("BlogFrontEnd.AddTags", "Add a tag? (optional)"), $this->owner->Tags()->map()));
}
if ($id && ($post = BlogPost::get()->byID($id))) {
$form->loadDataFrom($post);
}
$this->owner->extend("updateFrontEndPostForm", $form);
return $form;
}
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-blog-frontend,代码行数:36,代码来源:BlogFrontEndForm_BlogController.php
示例7: ItemEditForm
/**
* @return Form
*/
public function ItemEditForm()
{
if (!$this->record->isPublished()) {
Versioned::reading_stage('Stage');
}
if (!$this->record->ParentID) {
// set a parent id for the record, even if it will change
$parents = $this->record->getCatalogParents();
if ($parents && $parents->count()) {
$this->record->ParentID = $parents->first()->ID;
}
}
$form = parent::ItemEditForm();
if ($this->record->has_extension('CatalogPageExtension') || $this->record->has_extension('CatalogDataObjectExtension')) {
$actions = $form->Actions();
if ($this->record->ID) {
if ($this->record->isPublished()) {
$actions->push(FormAction::create('doDisable', _t('CatalogManager.DISABLE', 'Disable'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-destructive'));
} else {
$actions->push(FormAction::create('doEnable', _t('CatalogManager.ENABLE', 'Enable'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'));
}
}
if ($this->record->canCreate() && $this->record->stat('can_duplicate') == true) {
$actions->push(FormAction::create('doDuplicate', _t('CatalogManager.DUPLICATE', 'Duplicate'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'));
}
$form->setActions($actions);
}
$this->extend('updateItemEditForm', $form);
return $form;
}
开发者ID:helpfulrobot,项目名称:dospuntocero-silverstripe-catalogmanager,代码行数:33,代码来源:CatalogPageGridFieldDetailForm.php
示例8: __construct
public function __construct($controller, $name)
{
$member = Member::currentUser();
$requiredFields = null;
if ($member && $member->exists()) {
$fields = $member->getMemberFormFields();
$fields->removeByName('Password');
$requiredFields = $member->getValidator();
$requiredFields->addRequiredField('Surname');
} else {
$fields = FieldList::create();
}
if (get_class($controller) == 'AccountPage_Controller') {
$actions = FieldList::create(FormAction::create('submit', _t('MemberForm.SAVE', 'Save Changes')));
} else {
$actions = FieldList::create(FormAction::create('submit', _t('MemberForm.SAVE', 'Save Changes')), FormAction::create('proceed', _t('MemberForm.SAVEANDPROCEED', 'Save and proceed to checkout')));
}
parent::__construct($controller, $name, $fields, $actions, $requiredFields);
$this->extend('updateShopAccountForm');
if ($record = $controller->data()) {
$record->extend('updateShopAccountForm', $fields, $actions, $requiredFields);
}
if ($controller->data() && $controller->data()->hasMethod('updateShopAccountForm')) {
// if accessing through the model
Deprecation::notice('2.0', 'Please access updateShopAccountForm through ShopAccountForm instead of AccountPage (this extension point is due to be removed)');
}
if ($member) {
$member->Password = "";
//prevents password field from being populated with encrypted password data
$this->loadDataFrom($member);
}
}
示例9: UpdateForm
public function UpdateForm()
{
$member = singleton('SecurityContext')->getMember();
if (!$member) {
return '';
}
// if there's a member profile page availble, use it
$filter = array();
if (class_exists('Multisites')) {
$filter = array('SiteID' => Multisites::inst()->getCurrentSiteId());
}
// use member profile page if possible
if (class_exists('MemberProfilePage') && ($profilePage = MemberProfilePage::get()->filter($filter)->first())) {
$controller = MemberProfilePage_Controller::create($profilePage);
$form = $controller->ProfileForm();
$form->addExtraClass('ajax-form');
$form->loadDataFrom($member);
return $form;
} else {
$password = new ConfirmedPasswordField('Password', $member->fieldLabel('Password'), null, null, (bool) $this->ID);
$password->setCanBeEmpty(true);
$fields = FieldList::create(TextField::create('FirstName', $member->fieldLabel('FirstName')), TextField::create('Surname', $member->fieldLabel('Surname')), EmailField::create('Email', $member->fieldLabel('Email')), $password);
$actions = FieldList::create($update = FormAction::create('updateprofile', 'Update'));
$form = Form::create($this, 'UpdateForm', $fields, $actions);
$form->loadDataFrom($member);
$this->extend('updateProfileDashletForm', $form);
return $form;
}
return;
}
示例10: __construct
/**
* EmailVerificationLoginForm is the same as MemberLoginForm with the following changes:
* - The code has been cleaned up.
* - A form action for users who have lost their verification email has been added.
*
* We add fields in the constructor so the form is generated when instantiated.
*
* @param Controller $controller The parent controller, necessary to create the appropriate form action tag.
* @param string $name The method on the controller that will return this form object.
* @param FieldList|FormField $fields All of the fields in the form - a {@link FieldList} of {@link FormField} objects.
* @param FieldList|FormAction $actions All of the action buttons in the form - a {@link FieldList} of {@link FormAction} objects
* @param bool $checkCurrentUser If set to TRUE, it will be checked if a the user is currently logged in, and if so, only a logout button will be rendered
*/
function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
{
$email_field_label = singleton('Member')->fieldLabel(Member::config()->unique_identifier_field);
$email_field = TextField::create('Email', $email_field_label, null, null, $this)->setAttribute('autofocus', 'autofocus');
$password_field = PasswordField::create('Password', _t('Member.PASSWORD', 'Password'));
$authentication_method_field = HiddenField::create('AuthenticationMethod', null, $this->authenticator_class, $this);
$remember_me_field = CheckboxField::create('Remember', 'Remember me next time?', true);
if ($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) {
$fields = FieldList::create($authentication_method_field);
$actions = FieldList::create(FormAction::create('logout', _t('Member.BUTTONLOGINOTHER', "Log in as someone else")));
} else {
if (!$fields) {
$fields = FieldList::create($authentication_method_field, $email_field, $password_field);
if (Security::config()->remember_username) {
$email_field->setValue(Session::get('SessionForms.MemberLoginForm.Email'));
} else {
// Some browsers won't respect this attribute unless it's added to the form
$this->setAttribute('autocomplete', 'off');
$email_field->setAttribute('autocomplete', 'off');
}
}
if (!$actions) {
$actions = FieldList::create(FormAction::create('doLogin', _t('Member.BUTTONLOGIN', "Log in")), new LiteralField('forgotPassword', '<p id="ForgotPassword"><a href="Security/lostpassword">' . _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>'), new LiteralField('resendEmail', '<p id="ResendEmail"><a href="Security/verify-email">' . _t('MemberEmailVerification.BUTTONLOSTVERIFICATIONEMAIL', "I've lost my verification email") . '</a></p>'));
}
}
if (isset($_REQUEST['BackURL'])) {
$fields->push(HiddenField::create('BackURL', 'BackURL', $_REQUEST['BackURL']));
}
// Reduce attack surface by enforcing POST requests
$this->setFormMethod('POST', true);
parent::__construct($controller, $name, $fields, $actions);
$this->setValidator(RequiredFields::create('Email', 'Password'));
}
开发者ID:jordanmkoncz,项目名称:silverstripe-memberemailverification,代码行数:46,代码来源:EmailVerificationLoginForm.php
示例11: build
/**
* @param IRSVPTemplate $template
* @param IRSVP $rsvp
* @param ISummitEvent $event
* @param string $form_name
* @return BootstrapForm|PresentationSpeaker
*/
public function build(IRSVPTemplate $template, IRSVP $rsvp, ISummitEvent $event, $form_name = 'RSVPForm')
{
$fields = new FieldList();
foreach ($template->getQuestions() as $q) {
$type = $q->Type();
$builder_class = $type . 'UIBuilder';
// @IRSVPQuestionTemplateUIBuilder
$builder = Injector::inst()->create($builder_class);
$answer = $rsvp ? $rsvp->findAnswerByQuestion($q) : null;
$field = $builder->build($rsvp, $q, $answer);
$fields->add($field);
}
$validator = null;
if ($rsvp) {
$fields->add(new HiddenField('rsvp_id', 'rsvp_id', $rsvp->getIdentifier()));
}
$fields->add(new HiddenField('event_id', 'event_id', $event->getIdentifier()));
$fields->add(new HiddenField('summit_id', 'summit_id', $event->Summit()->getIdentifier()));
$fields->add(new HiddenField('seat_type', 'seat_type', $event->getCurrentRSVPSubmissionSeatType()));
$fields->add(new LiteralField('hr', '<hr>'));
$actions = new FieldList(FormAction::create('submit_rsvp')->setTitle('Send RSVP')->addExtraClass('rsvp_submit'));
$form = new BootstrapForm(Controller::curr(), $form_name . '_' . $event->getIdentifier(), $fields, $actions, $validator);
$form->setAttribute('class', 'rsvp_form');
return $form;
}
示例12: __construct
/**
* @param Controller $controller
* @param String $name
* @param array $arguments
*/
public function __construct($controller, $name, $arguments = array())
{
/** -----------------------------------------
* Fields
* ----------------------------------------*/
/** @var EmailField $email */
$email = EmailField::create('Email', 'Email Address');
$email->addExtraClass('form-control')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Email</strong>')->setCustomValidationMessage('Please enter your <strong>Email</strong>');
$fields = FieldList::create($email);
/** -----------------------------------------
* Actions
* ----------------------------------------*/
$actions = FieldList::create(FormAction::create('Subscribe')->setTitle('Subscribe')->addExtraClass('btn btn-primary'));
/** -----------------------------------------
* Validation
* ----------------------------------------*/
$required = RequiredFields::create('Email');
/** @var Form $form */
$form = Form::create($this, $name, $fields, $actions, $required);
if ($formData = Session::get('FormInfo.Form_' . $name . '.data')) {
$form->loadDataFrom($formData);
}
parent::__construct($controller, $name, $fields, $actions, $required);
$this->setAttribute('data-parsley-validate', true);
$this->addExtraClass('form');
}
示例13: AddForm
/**
* @return Form
*/
public function AddForm()
{
$fields = new FieldList(new LiteralField('SelectFieldType', '<p><strong>Please select a field type to add:</strong></p>'), $df = new DropdownField('ClassName', '', $this->getFieldTypes(), null, null));
$df->setHasEmptyDefault(true);
if ($schemaID = (int) $this->request->param('ID')) {
$fields->push(new HiddenField('SchemaID', '', $schemaID));
}
$actions = new FieldList(FormAction::create('doAddField', 'Create')->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'));
// Add a Cancel link which is a button-like link and link back to one level up.
$curmbs = $this->Breadcrumbs();
if ($curmbs && $curmbs->count() >= 2) {
$one_level_up = $curmbs->offsetGet($curmbs->count() - 2);
$text = "\n\t\t\t<a class=\"crumb ss-ui-button ss-ui-action-destructive cms-panel-link ui-corner-all\" href=\"" . $one_level_up->Link . "\">\n\t\t\t\tCancel\n\t\t\t</a>";
$actions->push(new LiteralField('cancelbutton', $text));
}
$form = new Form($this, 'AddForm', $fields, $actions);
$toplevelController = $this->getToplevelController();
$form->setTemplate('LeftAndMain_EditForm');
$form->addExtraClass('cms-content cms-edit-form center ss-tabset stacked');
$form->setAttribute('data-pjax-fragment', 'CurrentForm Content');
if ($form->Fields()->hasTabset()) {
$form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
}
//var_dump($this->popupController); die;
$parents = $this->popupController->Breadcrumbs(false)->items;
$form->Backlink = array_pop($parents)->Link;
return $form;
}
示例14: updateItemEditForm
public function updateItemEditForm($form)
{
if ($this->owner->record->ClassName !== 'Application') {
return $form;
}
$actions = $form->Actions();
$canSubmitOrg = $this->owner->record->canSubmitOrg();
$canReturnRevising = $this->owner->record->canReturnRevising();
$canOfficeApprove = $this->owner->record->canOfficeApprove();
$canAdminApprove = $this->owner->record->canAdminApprove();
$canInitiate = $this->owner->record->canInitiate();
$canFail = $this->owner->record->canFail();
if ($canSubmitOrg) {
$actions->push(FormAction::create('doSubmitOrg', '上报企业')->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'));
}
if ($canOfficeApprove) {
$actions->push(FormAction::create('doOfficeApprove', '初审通过')->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'));
}
if ($canAdminApprove) {
$actions->push(FormAction::create('doAdminApprove', '审核通过')->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'));
}
if ($canReturnRevising) {
$actions->push(FormAction::create('doReturnRevising', '退回修改')->setUseButtonTag(true)->addExtraClass('ss-ui-action-destructive'));
}
if ($canInitiate) {
$actions->push(FormAction::create('doInitiate', '立项')->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'));
}
if ($canFail) {
$actions->push(FormAction::create('doFail', '审核落选')->setUseButtonTag(true)->addExtraClass('ss-ui-action-destructive'));
}
}
示例15: BillingAddressForm
public function BillingAddressForm()
{
$form = CheckoutForm::create($this->owner, 'BillingAddressForm', $this->billingconfig());
$form->setActions(FieldList::create(FormAction::create("setbillingaddress", _t('CheckoutStep.Continue', "Continue"))));
$this->owner->extend('updateBillingAddressForm', $form);
return $form;
}