本文整理汇总了PHP中Form::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::__construct方法的具体用法?PHP Form::__construct怎么用?PHP Form::__construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Form
的用法示例。
在下文中一共展示了Form::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param Controller $controller
* @param Job $job (optional)
*/
public function __construct($controller, $job = null)
{
if ($job) {
$fields = $job->getFields();
$required = $job->getValidator();
} else {
$fields = singleton('Job')->getFields();
$required = singleton('Job')->getValidator();
}
$fields->merge(new FieldList(new LiteralField('Conditions', $controller->TermsAndConditionsText), new HiddenField('BackURL', '', $controller->Link('thanks')), new HiddenField('EmailFrom', '', $controller->getJobEmailFromAddress()), new HiddenField('EmailSubject', '', $controller->getJobEmailSubject()), $jobId = new HiddenField('JobID')));
if ($job) {
$jobId->setValue($job->ID);
$actions = new FieldList(new FormAction('doEditJob', _t('Jobboard.EDITLISTING', 'Edit Listing')));
} else {
$actions = new FieldList(new FormAction('doAddJob', _t('JobBoard.CONFIRM', 'Confirm')));
}
parent::__construct($controller, 'AddJobForm', $fields, $actions, $required);
$this->setFormAction('JobBoardFormProcessor/doJobForm');
$this->setFormMethod('POST');
if ($job) {
$this->loadDataFrom($job);
} else {
$this->enableSpamProtection();
}
}
示例2: __construct
public function __construct($id = false)
{
parent::__construct();
$this->add("products");
$this->name = "form_slider";
$this->enctype = "multipart/form-data";
$this->action = URL::current();
$this->products = ProductDB::getAdminShow();
if (!$id) {
$this->text("title", "Название:");
$this->textarea("description", "Описание:");
$this->submit("insert_slider", "Сохранить");
} else {
$this->add("img");
$this->add("product_id");
$this->hidden("id", $id);
$obj = new SliderDB();
$obj->load($id);
$this->text("title", "Название:", $obj->title);
$img = ProductDB::getCellOnID($obj->product_id, "img");
$view = new View(Config::DIR_TMPL);
$this->img = $view->render("img", array("src" => Config::DIR_IMG_PRODUCT . $img), true);
$this->textarea("description", "Описание:", $obj->description);
$this->submit("update_slider", "Сохранить");
$this->product_id = $obj->product_id;
}
}
示例3: __construct
public function __construct($controller, $name = "CartForm", $cart = null, $template = "Cart")
{
$this->cart = $cart;
$fields = new FieldList(CartEditField::create("Items", "", $this->cart)->setTemplate($template));
$actions = new FieldList(FormAction::create("updatecart", "Update Cart"));
parent::__construct($controller, $name, $fields, $actions);
}
示例4: __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');
}
示例5: __construct
public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null)
{
parent::__construct($controller, $name, $fields, $actions, $validator);
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-form/jquery.form.js');
$name = $this->FormName();
$action = $this->FormAction();
$loading = _t('BootstrapAjaxForm.LOADING', 'BootstrapAjaxForm.LOADING');
$js = <<<JS
(function(\$){
\$(function(){
\$('#{$name}').ajaxForm({
delegation: true,
target: '#AjaxForm_{$name}',
beforeSubmit: function(data, form, options){
\$('#{$name} [type=submit]').prop("disabled", true).html('{$loading}');
}
\t});
});
})(jQuery);
JS;
Requirements::customScript($js, 'BootstrapAjaxForm_Js_' . $this->FormName());
if (!Director::is_ajax()) {
$this->setTemplate('BootstrapAjaxForm');
}
}
示例6: __construct
/**
* Class constructor
*
*/
public function __construct($plugins)
{
parent::__construct('configForm');
$language = OW::getLanguage();
$values = OW::getConfig()->getValues('uheader');
if ($plugins['photo']) {
$field = new CheckboxField('photo_share');
$field->setId('photo_share_check');
$field->setValue($values['photo_share']);
$this->addElement($field);
$field = new TextField('photo_album_name');
$field->setValue(OW::getLanguage()->text('uheader', 'default_photo_album_name'));
$field->setRequired();
$this->addElement($field);
}
$field = new TextField('cover_height');
$field->setValue($values['cover_height']);
$field->addValidator(new IntValidator(self::COVER_MIN_HEIGHT, self::COVER_MAX_HEIGHT));
$field->setRequired();
$this->addElement($field);
// submit
$submit = new Submit('save');
$submit->setValue($language->text('uheader', 'config_save_label'));
$this->addElement($submit);
}
示例7: __construct
public function __construct($ctrl)
{
parent::__construct('settings-form');
$configs = OW::getConfig()->getValues('yncontactimporter');
$ctrl->assign('configs', $configs);
$l = OW::getLanguage();
$miValidator = new IntValidator(1, 999);
$miValidator->setErrorMessage($l->text('yncontactimporter', 'max_validation_error', array('min' => 1, 'max' => 999)));
//Contacts per page
$textField['contact_per_page'] = new TextField('contact_per_page');
$textField['contact_per_page']->setLabel($l->text('yncontactimporter', 'settings_contact_per_page'))->setValue($configs['contact_per_page'])->addValidator($miValidator)->setRequired(true);
$this->addElement($textField['contact_per_page']);
//Maximum invite per times
$textField['max_invite_per_times'] = new TextField('max_invite_per_times');
$textField['max_invite_per_times']->setLabel($l->text('yncontactimporter', 'settings_max_invite_per_times'))->setValue($configs['max_invite_per_times'])->addValidator($miValidator)->setRequired(true);
$this->addElement($textField['max_invite_per_times']);
//Default invite message
$textField['default_invite_message'] = new Textarea('default_invite_message');
$textField['default_invite_message']->setLabel($l->text('yncontactimporter', 'settings_default_invite_message'))->setValue($configs['default_invite_message']);
$this->addElement($textField['default_invite_message']);
// Logo width
$textField['logo_width'] = new TextField('logo_width');
$textField['logo_width']->setLabel($l->text('yncontactimporter', 'settings_logo_width'))->setValue($configs['logo_width'])->addValidator($miValidator)->setRequired(true);
$this->addElement($textField['logo_width']);
// Logo Height
$textField['logo_height'] = new TextField('logo_height');
$textField['logo_height']->setLabel($l->text('yncontactimporter', 'settings_logo_height'))->setValue($configs['logo_height'])->addValidator($miValidator)->setRequired(true);
$this->addElement($textField['logo_height']);
$submit = new Submit('submit');
$submit->setValue($l->text('yncontactimporter', 'save_btn_label'));
$submit->addAttribute('class', 'ow_ic_save ow_positive');
$this->addElement($submit);
}
示例8: __construct
public function __construct($controller, $name)
{
$product = new Product();
$title = new TextField('Title', _t('Product.PAGETITLE', 'Product Title'));
$urlSegment = new TextField('URLSegment', 'URL Segment');
$menuTitle = new TextField('MenuTitle', 'Navigation Title');
$sku = TextField::create('InternalItemID', _t('Product.CODE', 'Product Code/SKU'), '', 30);
$categories = DropdownField::create('ParentID', _t("Product.CATEGORY", "Category"), $product->categoryoptions())->setDescription(_t("Product.CATEGORYDESCRIPTION", "This is the parent page or default category."));
$otherCategories = ListBoxField::create('ProductCategories', _t("Product.ADDITIONALCATEGORIES", "Additional Categories"), ProductCategory::get()->filter("ID:not", $product->getAncestors()->map('ID', 'ID'))->map('ID', 'NestedTitle')->toArray())->setMultiple(true);
$model = TextField::create('Model', _t('Product.MODEL', 'Model'), '', 30);
$featured = CheckboxField::create('Featured', _t('Product.FEATURED', 'Featured Product'));
$allow_purchase = CheckboxField::create('AllowPurchase', _t('Product.ALLOWPURCHASE', 'Allow product to be purchased'), 1, 'Content');
$price = TextField::create('BasePrice', _t('Product.PRICE', 'Price'))->setDescription(_t('Product.PRICEDESC', "Base price to sell this product at."))->setMaxLength(12);
$image = UploadField::create('Image', _t('Product.IMAGE', 'Product Image'));
$content = new HtmlEditorField('Content', 'Content');
$fields = new FieldList();
$fields->add($title);
//$fields->add($urlSegment);
//$fields->add($menuTitle);
//$fields->add($sku);
$fields->add($categories);
//$fields->add($otherCategories);
$fields->add($model);
$fields->add($featured);
$fields->add($allow_purchase);
$fields->add($price);
$fields->add($image);
$fields->add($content);
//$fields = $product->getFrontEndFields();
$actions = new FieldList(new FormAction('submit', _t("ChefProductForm.ADDPRODUCT", 'Add product')));
$requiredFields = new RequiredFields(array('Title', 'Model', 'Price'));
parent::__construct($controller, $name, $fields, $actions, $requiredFields);
}
示例9:
/**
* Constructor
*
* @param HTMLOutputter $out output channel
* @param Profile $profile profile of user to block
* @param User_group $group group to block user from
* @param array $args return-to args
*/
function __construct($out = null, $profile = null, $group = null, $args = null)
{
parent::__construct($out);
$this->profile = $profile;
$this->group = $group;
$this->args = $args;
}
示例10: __construct
public function __construct($view, $param)
{
parent::__construct();
$this->add("hornav");
$this->add("n");
$this->name = "form_viewgallery";
$this->enctype = "multipart/form-data";
$this->action = URL::current();
$viewgallery_obj = new ViewgalleryDB();
$viewgallery_obj->load($param["view_id"]);
$this->hornav = new Hornav();
$this->hornav->addData("Админпанель", URL::get("menu", "admin"));
$this->hornav->addData("Галерея", URL::get("viewgallery", "admin"));
$this->hornav->addData($viewgallery_obj->title, URL::get("listgallery", "admin", array("view_id" => $param["view_id"])));
if (!$param["gallery_id"]) {
$this->hornav->addData("Добавить");
$this->text("title", "Название:", FormProcessor::getSessionData("title"));
$this->file("img", "Картинка:");
$this->textarea("meta_desc", "Описание:", FormProcessor::getSessionData("meta_desc"));
$this->textarea("meta_key", "Ключевые слова:", FormProcessor::getSessionData("meta_key"));
$this->submit("insert_listgallery", "Сохранить");
} else {
$this->hidden("id", $param["gallery_id"]);
$gallery_obj = new GalleryDB();
$gallery_obj->load($param["gallery_id"]);
$this->hornav->addData("Изменить");
$this->text("title", "Название:", $gallery_obj->title);
$this->file("img", "Картинка:");
$this->textarea("meta_desc", "Описание:", $gallery_obj->meta_desc);
$this->textarea("meta_key", "Ключевые слова:", $gallery_obj->meta_key);
$this->submit("update_listgallery", "Сохранить");
}
}
示例11: __construct
public function __construct($configs, $features)
{
parent::__construct('MCOMPOSE_ConfigForm');
$this->configs = $configs;
$language = OW::getLanguage();
$field = new TextField('max_users');
$field->setRequired();
$field->setValue($configs['max_users']);
$this->addElement($field);
if ($features["friends"]) {
$field = new CheckboxField('friends_enabled');
$field->setValue($configs['friends_enabled']);
$this->addElement($field);
}
if ($features["groups"]) {
$field = new CheckboxField('groups_enabled');
$field->setValue($configs['groups_enabled']);
$this->addElement($field);
}
if ($features["events"]) {
$field = new CheckboxField('events_enabled');
$field->setValue($configs['events_enabled']);
$this->addElement($field);
}
// submit
$submit = new Submit('save');
$submit->setValue($language->text('mcompose', 'admin_save_btn'));
$this->addElement($submit);
}
示例12: FormValidatorPost
/**
* Constructor.
* @param $submissionId int Submission ID
* @param $template string Template filename
*/
function __construct($submissionId, $template)
{
parent::__construct($template);
$this->_submissionId = (int) $submissionId;
$this->addCheck(new FormValidatorPost($this));
$this->addCheck(new FormValidatorCSRF($this));
}
示例13:
function __construct($action, $profile)
{
parent::__construct($action);
$this->profile = clone $profile;
$this->user = common_current_user();
$this->mirror = SubMirror::pkeyGet(array('subscriber' => $this->user->id, 'subscribed' => $this->profile->id));
}
示例14: FormValidatorEmail
/**
* Constructor
*/
function __construct()
{
for ($i = SUBSCRIPTION_OPEN_ACCESS_DELAY_MIN; $i <= SUBSCRIPTION_OPEN_ACCESS_DELAY_MAX; $i++) {
$this->validDuration[$i] = $i;
}
for ($i = SUBSCRIPTION_EXPIRY_REMINDER_BEFORE_MONTHS_MIN; $i <= SUBSCRIPTION_EXPIRY_REMINDER_BEFORE_MONTHS_MAX; $i++) {
$this->validNumMonthsBeforeExpiry[$i] = $i;
}
for ($i = SUBSCRIPTION_EXPIRY_REMINDER_BEFORE_WEEKS_MIN; $i <= SUBSCRIPTION_EXPIRY_REMINDER_BEFORE_WEEKS_MAX; $i++) {
$this->validNumWeeksBeforeExpiry[$i] = $i;
}
for ($i = SUBSCRIPTION_EXPIRY_REMINDER_AFTER_MONTHS_MIN; $i <= SUBSCRIPTION_EXPIRY_REMINDER_AFTER_MONTHS_MAX; $i++) {
$this->validNumMonthsAfterExpiry[$i] = $i;
}
for ($i = SUBSCRIPTION_EXPIRY_REMINDER_AFTER_WEEKS_MIN; $i <= SUBSCRIPTION_EXPIRY_REMINDER_AFTER_WEEKS_MAX; $i++) {
$this->validNumWeeksAfterExpiry[$i] = $i;
}
parent::__construct('subscription/subscriptionPolicyForm.tpl');
// If provided, subscription contact email is valid
$this->addCheck(new FormValidatorEmail($this, 'subscriptionEmail', 'optional', 'manager.subscriptionPolicies.subscriptionContactEmailValid'));
// If provided delayed open access duration is valid value
$this->addCheck(new FormValidatorInSet($this, 'delayedOpenAccessDuration', 'optional', 'manager.subscriptionPolicies.delayedOpenAccessDurationValid', array_keys($this->validDuration)));
// If provided expiry reminder months before value is valid value
$this->addCheck(new FormValidatorInSet($this, 'numMonthsBeforeSubscriptionExpiryReminder', 'optional', 'manager.subscriptionPolicies.numMonthsBeforeSubscriptionExpiryReminderValid', array_keys($this->validNumMonthsBeforeExpiry)));
// If provided expiry reminder weeks before value is valid value
$this->addCheck(new FormValidatorInSet($this, 'numWeeksBeforeSubscriptionExpiryReminder', 'optional', 'manager.subscriptionPolicies.numWeeksBeforeSubscriptionExpiryReminderValid', array_keys($this->validNumWeeksBeforeExpiry)));
// If provided expiry reminder months after value is valid value
$this->addCheck(new FormValidatorInSet($this, 'numMonthsAfterSubscriptionExpiryReminder', 'optional', 'manager.subscriptionPolicies.numMonthsAfterSubscriptionExpiryReminderValid', array_keys($this->validNumMonthsAfterExpiry)));
// If provided expiry reminder weeks after value is valid value
$this->addCheck(new FormValidatorInSet($this, 'numWeeksAfterSubscriptionExpiryReminder', 'optional', 'manager.subscriptionPolicies.numWeeksAfterSubscriptionExpiryReminderValid', array_keys($this->validNumWeeksAfterExpiry)));
$this->addCheck(new FormValidatorPost($this));
$this->addCheck(new FormValidatorCSRF($this));
}
示例15: TextField
function __construct($controller, $name)
{
$org_field = null;
$current_user = Member::currentUser();
$current_affiliations = $current_user->getCurrentAffiliations();
if (!$current_affiliations) {
$org_field = new TextField('Organization', 'Your Organization Name');
} else {
if (count($current_affiliations) > 1) {
$source = array();
foreach ($current_affiliations as $a) {
$org = $a->Organization();
$source[$org->ID] = $org->Name;
}
$source['0'] = "-- New One --";
$ddl = new DropdownField('OrgID', 'Your Organization', $source);
$ddl->setEmptyString('-- Select Your Organization --');
$org_field = new FieldGroup();
$org_field->push($ddl);
$org_field->push($txt = new TextField('Organization', ''));
$txt->addExtraClass('new-org-name');
} else {
$org_field = new TextField('Organization', 'Your Organization Name', $current_user->getOrgName());
}
}
$fields = new FieldList($org_field, new DropdownField('Industry', 'Your Organization’s Primary Industry', ArrayUtils::AlphaSort(DeploymentSurveyOptions::$industry_options, array('' => '-- Please Select One --'), array('Other' => 'Other Industry (please specify)'))), new TextareaField('OtherIndustry', 'Other Industry'), $org_it_activity = new TextareaField('ITActivity', 'Your Organization’s Primary IT Activity'), new LiteralField('Break', '<hr/>'), new LiteralField('Break', '<p>Your Organization’s Primary Location or Headquarters</p>'), $country = new DropdownField('PrimaryCountry', 'Country', CountryCodes::$iso_3166_countryCodes), new TextField('PrimaryState', 'State / Province / Region'), new TextField('PrimaryCity', 'City'), new DropdownField('OrgSize', 'Your Organization Size (All Branches, Locations, Sites)', DeploymentSurveyOptions::$organization_size_options), new CustomCheckboxSetField('OpenStackInvolvement', 'What best describes your Organization’s involvement with OpenStack?<BR>Select All That Apply', ArrayUtils::AlphaSort(DeploymentSurveyOptions::$openstack_involvement_options)));
$org_it_activity->addExtraClass('hidden');
$country->setEmptyString('-- Select One --');
$nextButton = new FormAction('NextStep', ' Next Step ');
$actions = new FieldList($nextButton);
$validator = new RequiredFields();
Requirements::javascript('surveys/js/deployment_survey_yourorganization_form.js');
parent::__construct($controller, $name, $fields, $actions, $validator);
}