本文整理汇总了PHP中FormControl类的典型用法代码示例。如果您正苦于以下问题:PHP FormControl类的具体用法?PHP FormControl怎么用?PHP FormControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FormControl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Validates the data contained in the given form control using the validator
* specified by the given form control.
*
* @param FormControl $control
*
* @return boolean
*/
public function validate($control)
{
if (preg_match($this->getRegexpForValidator($control->getValidator()), $control->getData())) {
return TRUE;
}
return FALSE;
}
开发者ID:eguicciardi,项目名称:ada,代码行数:15,代码来源:FormValidator.inc.php
示例2: getControl
/**
* Generates control's HTML element.
* @return Html
*/
public function getControl()
{
$control = FormControl::getControl();
// skopirovany kod z SelectBox.php
if ($this->isFirstSkipped()) {
$items = $this->items;
reset($items);
$control->data['nette-empty-value'] = $this->areKeysUsed() ? key($items) : current($items);
}
$selected = $this->getValue();
$this->selected = is_array($selected) ? array_flip($selected) : array($selected => TRUE);
$this->formatOptions($this->items, $control);
return $control;
}
开发者ID:radypala,项目名称:maga-website,代码行数:18,代码来源:MySelectBox.php
示例3: __construct
public function __construct($formName, $courseList)
{
parent::__construct();
$this->setName($formName);
$this->addHidden('id');
$this->addHidden('recipientsCount')->withData(0);
$this->addHidden('enqueuedmsg')->withData(translateFN('Newsletter inoltrata per l\'invio'));
$userType = FormControl::create(FormControl::SELECT, 'userType', translateFN('Tipo Utente'))->withData(array(0 => translateFN('Scegli il tipo...'), AMA_TYPE_AUTHOR => translateFN('Autore'), AMA_TYPE_STUDENT => translateFN('Studente'), AMA_TYPE_TUTOR => translateFN('Tutor'), AMA_TYPE_SWITCHER => translateFN('Switcher'), 9999 => translateFN('Tutti')), 0)->setRequired()->setValidator(FormValidator::POSITIVE_NUMBER_VALIDATOR);
$userPlatformStatus = FormControl::create(FormControl::SELECT, 'userPlatformStatus', translateFN('Stato Studente nella Piattaforma'))->withData(array(-1 => translateFN('Scegli lo stato...'), ADA_STATUS_PRESUBSCRIBED => translateFN('Non Confermato'), ADA_STATUS_REGISTERED => translateFN('Confermato')), -1)->setAttribute('disabled', 'true')->setValidator(FormValidator::POSITIVE_NUMBER_VALIDATOR);
$userCourseStatus = FormControl::create(FormControl::SELECT, 'userCourseStatus', translateFN('Stato Studente nel corso selezionato'))->withData(array(-1 => translateFN('Scegli lo stato...'), ADA_SERVICE_SUBSCRIPTION_STATUS_UNDEFINED => translateFN('In visita'), ADA_SERVICE_SUBSCRIPTION_STATUS_REQUESTED => translateFN('Preiscritto'), ADA_SERVICE_SUBSCRIPTION_STATUS_ACCEPTED => translateFN('Iscritto'), ADA_SERVICE_SUBSCRIPTION_STATUS_SUSPENDED => translateFN('Rimosso'), ADA_SERVICE_SUBSCRIPTION_STATUS_COMPLETED => translateFN('Completato')), -1)->setAttribute('disabled', 'true')->setValidator(FormValidator::POSITIVE_NUMBER_VALIDATOR);
$this->addFieldset(translateFN('Filtro') . ' ' . translateFN('Utenti'), 'userChoice')->withData(array($userType, $userPlatformStatus, $userCourseStatus));
$courseList[0] = translateFN('Scegli il corso...');
$courseSel = FormControl::create(FormControl::SELECT, 'idCourse', translateFN('Corso'))->withData($courseList, 0)->setAttribute('disabled', 'true')->setValidator(FormValidator::POSITIVE_NUMBER_VALIDATOR);
$instanceSel = FormControl::create(FormControl::SELECT, 'idInstance', translateFN('Istanza Corso'))->setAttribute('disabled', 'true')->setValidator(FormValidator::POSITIVE_NUMBER_VALIDATOR);
$this->addFieldset(translateFN('Filtro') . ' ' . translateFN('Corsi'), 'courseChoice')->withData(array($courseSel, $instanceSel));
$this->setSubmitValue(translateFN('Invia Newsletter'));
}
开发者ID:eguicciardi,项目名称:ada,代码行数:17,代码来源:formFilterNewsletter.inc.php
示例4: get
/**
* Get this control for display
* @param Theme $theme The theme to use for rendering
* @return string The output
*/
public function get(Theme $theme)
{
$this->vars['element'] = $this->get_setting('wrap_element', 'div');
$content = '';
foreach ($this->value as $key => $data) {
// Push the $key of this array item into the control's name
$this->each(function (FormControl $control) use($key) {
$control->add_input_array($key);
});
$content .= $this->get_contents($theme);
// Pop the key of this array item out of the control's name
$this->each(function (FormControl $control) {
$control->pop_input_array();
});
}
$this->vars['content'] = $content;
return FormControl::get($theme);
}
开发者ID:habari,项目名称:system,代码行数:23,代码来源:formcontrolrepeater.php
示例5: controls_js
/**
* Render the controls.init script prior to the supplied script only if it hasn't already been rendered
* @param string $out An existing script that depends on controls.init
* @return string The script with the controls.init script prepended, if needed
*/
public function controls_js($out)
{
if (FormControl::$controls_js == false) {
$js = '
<script type="text/javascript">
if(controls==undefined){
var controls = {
init:function(fn){
if(fn!=undefined){
controls.inits.push(fn);
}else{
for(var i in controls.inits){
controls.inits[i]();
}
}
},
inits:[]
};
}
$(function(){
controls.init();
});
</script>';
$out = $js . $out;
FormControl::$controls_js = true;
}
return $out;
}
开发者ID:habari,项目名称:system,代码行数:33,代码来源:formcontrol.php
示例6: __construct
/**
* @author giorgio 29/mag/2013
*
* added extra parameter to constructor to allow editing of student confirmed registration
*
*/
public function __construct($languages = array(), $allowEditProfile = false, $allowEditConfirm = false, $action = null)
{
parent::__construct();
$this->addHidden('id_utente')->withData(0);
/*
* @author:Sara 20/05/2014
* Workaround to remove the Google-Chrome autocomplete functionality.
*/
$j = 'return remove_false_element()';
$this->setOnSubmit($j);
$false_username = FormControl::create(FormControl::INPUT_TEXT, 'false_username', '');
$false_password = FormControl::create(FormControl::INPUT_PASSWORD, 'false_password', '');
$false_elements_fieldset = FormControl::create(FormControl::FIELDSET, 'false_elements_fieldset', '');
$false_elements_fieldset->setHidden();
$false_elements_fieldset->withData(array($false_username, $false_password));
$this->addControl($false_elements_fieldset);
$this->addPasswordInput('password', translateFN('Password'));
//->setValidator(FormValidator::PASSWORD_VALIDATOR);
$this->addPasswordInput('passwordcheck', translateFN('Conferma la password'));
/**
* If the swithcer does not use this form to edit her own
* profile, the avatar upload must be disabled
*/
if ($_SESSION['sess_userObj']->getType() != AMA_TYPE_SWITCHER || !$allowEditConfirm) {
$this->addFileInput('avatarfile', translateFN('Seleziona un file immagine per il tuo avatar'));
$this->addTextInput('avatar', NULL);
}
if ($action != null) {
$this->setAction($action);
}
/// $this->addTextInput('telefono', translateFN('Telefono'));
$telefono = FormControl::create(FormControl::INPUT_TEXT, 'telefono', translateFN('Telefono'));
$cap = FormControl::create(FormControl::INPUT_TEXT, 'cap', translateFN('cap'));
$citta = FormControl::create(FormControl::INPUT_TEXT, 'citta', translateFN('Città'));
$indirizzo = FormControl::create(FormControl::INPUT_TEXT, 'indirizzo', translateFN('Indirizzo'));
$provincia = FormControl::create(FormControl::INPUT_TEXT, 'provincia', translateFN('Provincia'));
$countries = countriesList::getCountriesList($_SESSION['sess_user_language']);
$nazione = FormControl::create(FormControl::SELECT, 'nazione', translateFN('Nazione'));
$nazione->withData($countries);
$this->addFieldset(translateFN('Dati residenza'), 'residenza')->withData(array($indirizzo, $cap, $citta, $provincia, $nazione, $telefono));
// $this->addTextInput('indirizzo', translateFN('Indirizzo'));
// $this->addTextInput('citta', translateFN('Città'));
// $this->addTextInput('provincia', translateFN('Provincia'));
/*
$countries = countriesList::getCountriesList($_SESSION['sess_user_language']);
$this->addSelect(
'nazione',
translateFN('Nazione'),
$countries,
'IT');
*
*/
$this->addTextInput('codice_fiscale', translateFN('Cod. Fiscale'));
/**
* @author giorgio 29/mag/2013
*
* added select field to allow editing of user confirmed registration status
*/
if ($allowEditConfirm) {
$this->addSelect('stato', translateFN('Confermato'), array(ADA_STATUS_PRESUBSCRIBED => translateFN('No'), ADA_STATUS_REGISTERED => translateFN('Si')), 0);
}
//->setValidator(FormValidator::PASSWORD_VALIDATOR);
if ($allowEditProfile) {
$this->addTextarea('profilo', translateFN('Il tuo profilo utente'));
}
$layoutsAr = array('' => translateFN('seleziona un layout'));
$layoutObj = new UILayout();
$avalaibleLayoutAr = $layoutObj->getAvailableLayouts();
$layouts = array_merge($layoutsAr, $avalaibleLayoutAr);
$this->addSelect('layout', translateFN('Layout'), $layouts, 0);
if (is_array($languages) && count($languages) > 0) {
$languagesAr[0] = translateFN('seleziona una lingua');
$languages = array_replace($languagesAr, $languages);
// $languages = array_merge($languagesAr,$languages);
$this->addSelect('lingua', translateFN('Lingua'), $languages, 0);
}
}
开发者ID:eguicciardi,项目名称:ada,代码行数:83,代码来源:UserProfileForm.inc.php
示例7: createComponentForm
/**
* Component factory.
* @see Nette/ComponentContainer#createComponent()
*/
protected function createComponentForm($name)
{
// NOTE: signal-submit on form disregard component's state
// because form is created directly by Presenter in signal handling phase
// and this principle is used to detect submit signal
if (!$this->wasRendered) {
$this->receivedSignal = 'submit';
}
$form = new AppForm($this, $name);
$form->setTranslator($this->getTranslator());
FormControl::$idMask = 'frm-datagrid-' . $this->getUniqueId() . '-%s-%s';
$form->onSubmit[] = array($this, 'formSubmitHandler');
$form->addSubmit('resetSubmit', 'Reset state');
$form->addSubmit('filterSubmit', 'Apply filters');
$form->addSelect('operations', 'Selected:', $this->operations);
$form->addSubmit('operationSubmit', 'Send')->onClick = $this->onOperationSubmit;
// page input
$form->addText('page', 'Page', 1);
$form['page']->setDefaultValue($this->page);
$form->addSubmit('pageSubmit', 'Change page');
// items per page selector
$form->addSelect('items', 'Items per page', array_combine($this->displayedItems, $this->displayedItems));
$form['items']->setDefaultValue($this->itemsPerPage);
$form->addSubmit('itemsSubmit', 'Change');
// generate filters FormControls
if ($this->hasFilters()) {
$defaults = array();
$sub = $form->addContainer('filters');
foreach ($this->getFilters() as $filter) {
$sub->addComponent($filter->getFormControl(), $filter->getName());
// NOTE: must be setted after is FormControl conntected to the form
$defaults[$filter->getName()] = $filter->value;
}
$sub->setDefaults($defaults);
}
// checker
if ($this->hasOperations()) {
$sub = $form->addContainer('checker');
if ($this->isSignalReceiver('submit')) {
// NOTE: important!
$ds = clone $this->dataSource;
$this->filterItems();
}
foreach ($this->getRows() as $row) {
$sub->addCheckbox($row[$this->keyName], $row[$this->keyName]);
}
if (isset($ds)) {
$this->dataSource = $ds;
}
}
$renderer = $form->getRenderer();
$renderer->wrappers['controls']['container'] = NULL;
$renderer->wrappers['label']['container'] = NULL;
$renderer->wrappers['control']['container'] = NULL;
$form->setRenderer($renderer);
return;
}
开发者ID:romansklenar,项目名称:nette-datagrid,代码行数:61,代码来源:DataGrid.php
示例8: validate_range
/**
* A validation function that returns an error if the value passed is not within a specified range
*
* @param string $value A value to test if it is empty
* @param FormControl $control The control that defines the value
* @param FormContainer $container The container that holds the control
* @param float $min The minimum value, inclusive
* @param float $max The maximum value, inclusive
* @param string $warning An optional error message
* @return array An empty array if the value is value, or an array with strings describing the errors
*/
public static function validate_range($value, $control, $container, $min, $max, $warning = null)
{
if ($value < $min) {
if ($warning == null) {
$warning = _t('The value entered for %s is lesser than the minimum of %d.', array($control->get_label(), $min));
}
return array($warning);
} elseif ($value > $max) {
if ($warning == null) {
$warning = _t('The value entered for %s is greater than the maximum of %d.', array($control->get_label(), $max));
}
return array($warning);
} else {
return array();
}
}
开发者ID:habari,项目名称:system,代码行数:27,代码来源:formvalidators.php
示例9: set_value
/**
* Set the value of this control
* @param mixed $value The value to set
* @param bool $manually True if this value is set internally rather than being POSTed in the form
* @return FormControl $this
*/
public function set_value($value, $manually = true)
{
$this->node->value = $value;
return parent::set_value($value, $manually);
}
开发者ID:habari,项目名称:system,代码行数:11,代码来源:formcontroldom.php
示例10: set_for
/**
* Apply this label to a control
* @param FormControl $for The control that this label is for
* @return FormControlLabel $this
*/
public function set_for($for)
{
$this->properties['for'] = $for->get_id();
return $this;
}
开发者ID:habari,项目名称:system,代码行数:10,代码来源:formcontrollabel.php
示例11: notifyRule
/**
* New rule or condition notification callback.
* @param Rule
* @return void
*/
public function notifyRule(Rule $rule)
{
if ($rule->type === Rule::VALIDATOR && is_string($rule->operation) && strcasecmp($rule->operation, ':mimeType') === 0) {
$this->control->accept = $rule->arg;
}
parent::notifyRule($rule);
}
开发者ID:laiello,项目名称:webuntucms,代码行数:12,代码来源:FileUpload.php
示例12: set_value
public function set_value($value, $manually = true)
{
if ($value != false) {
$this->returned_value = $value;
}
return parent::set_value($value, $manually);
}
开发者ID:habari,项目名称:system,代码行数:7,代码来源:formcontrolcheckbox.php
示例13: notifyRule
public function notifyRule(Rule $rule)
{
if (is_string($rule->operation) && strcasecmp($rule->operation, ':float') === 0) {
$this->addFilter(array(__CLASS__, 'filterFloat'));
}
parent::notifyRule($rule);
}
开发者ID:jaroslavlibal,项目名称:MDW,代码行数:7,代码来源:TextBase.php
示例14: validate
/**
* This control only validates if it's clicked
* @return array If empty, no errors. One string element describing each error
*/
public function validate()
{
if (isset($_POST[$this->input_name()])) {
return parent::validate();
}
return array();
}
开发者ID:habari,项目名称:system,代码行数:11,代码来源:formcontrolsubmit.php
示例15: get
public function get(Theme $theme)
{
$silos = Media::dir();
foreach ($silos as &$silo) {
$silo->path_slug = Utils::slugify($silo->path);
}
$this->vars['silos'] = $silos;
return parent::get($theme);
}
开发者ID:habari,项目名称:system,代码行数:9,代码来源:formcontrolsilos.php
示例16: attached
/**
* This method will be called when the component (or component's parent)
* becomes attached to a monitored object. Do not call this method yourself.
* @param IComponent
* @return void
*/
protected function attached($form)
{
if ($form instanceof Form) {
if ($form->getMethod() !== Form::POST) {
throw new InvalidStateException('File upload requires method POST.');
}
$form->getElementPrototype()->enctype = 'multipart/form-data';
}
parent::attached($form);
}
开发者ID:riskatlas,项目名称:micka,代码行数:16,代码来源:UploadControl.php
示例17: get
public function get(Theme $theme)
{
$this->properties['type'] = 'hidden';
$this->properties['data-facet-config'] = json_encode($this->properties['data-facet-config']);
$this->set_template_properties('div', array('id' => $this->get_visualizer(), 'data-target' => $this->get_id()));
return parent::get($theme);
}
开发者ID:habari,项目名称:system,代码行数:7,代码来源:formcontrolfacet.php
示例18: get
/**
* Produce HTML output for this text control.
*
* @param boolean $forvalidation True if this control should render error information based on validation.
* @return string HTML that will render this control in the form
*/
public function get(Theme $theme)
{
$this->vars['options'] = $this->options;
$this->settings['internal_value'] = true;
return parent::get($theme);
}
开发者ID:habari,项目名称:system,代码行数:12,代码来源:formcontrolselect.php
示例19: getControl
/**
* Generates control's HTML element.
* @return Nette\Web\Html
*/
public function getControl()
{
$control = parent::getControl();
$control->value = $this->translate($this->caption);
return $control;
}
开发者ID:vrana,项目名称:nette,代码行数:10,代码来源:Button.php
示例20: get
/**
* Return the HTML construction of the control, after changing the encoding of the parent form to allow for file uploads.
*
* @param boolean $forvalidation True if the control should output validation information with the control.
*/
public function get( $forvalidation = true )
{
$form = $this->get_form();
$form->properties['enctype'] = 'multipart/form-data';
return parent::get( $forvalidation );
}
开发者ID:nerdfiles,项目名称:habari_boilerplate,代码行数:12,代码来源:formui.php
注:本文中的FormControl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论