本文整理汇总了PHP中JFormFieldText::setup方法的典型用法代码示例。如果您正苦于以下问题:PHP JFormFieldText::setup方法的具体用法?PHP JFormFieldText::setup怎么用?PHP JFormFieldText::setup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFormFieldText
的用法示例。
在下文中一共展示了JFormFieldText::setup方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetupMaxlength
/**
* Tests maxLength attribute setup by JFormFieldText::setup method
*
* @covers JFormField::setup
* @covers JFormField::__get
*
* @return void
*/
public function testSetupMaxlength()
{
$field = new JFormFieldText();
$element = simplexml_load_string('<field name="myName" type="text" maxlength="60" />');
$this->assertThat($field->setup($element, ''), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
$this->assertThat($field->maxLength, $this->equalTo(60), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
}
示例2: testGetInput
/**
* Test the getInput method.
*
* @return void
*/
public function testGetInput()
{
$form = new JFormInspector('form1');
$this->assertThat(
$form->load('<form><field name="text" type="text" /></form>'),
$this->isTrue(),
'Line:' . __LINE__ . ' XML string should load successfully.'
);
$field = new JFormFieldText($form);
$this->assertThat(
$field->setup($form->getXml()->field, 'value'),
$this->isTrue(),
'Line:' . __LINE__ . ' The setup method should return true.'
);
$this->assertThat(
strlen($field->input),
$this->greaterThan(0),
'Line:' . __LINE__ . ' The getInput method should return something without error.'
);
// TODO: Should check all the attributes have come in properly.
}
示例3: setup
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$this->element = $element;
$element['label'] = $this->prepareText($element['label']);
$element['description'] = $this->prepareText($element['description']);
$element['translateDescription'] = false;
return parent::setup($element, $value, $group);
}
示例4: setup
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);
if ($result == true) {
$this->format = (string) $this->element['format'] ? (string) $this->element['format'] : 'Y-m-d';
}
return $result;
}
示例5: setup
public function setup(&$element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
$this->element['class'] = $this->element['class'] . ' color';
if ($this->element['name'] != 'title_color' and $this->element['name'] != 'date_color') {
$this->element['onchange'] = 'document.getElementById(\'jform_params_calendar_style\').value=\'custom\'';
}
return $return;
}
示例6: setup
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return) {
$this->countertext = isset($this->element['countertext']) ? (string) $this->element['countertext'] : '';
$this->countertext = JText::_($this->countertext);
$this->maxlength = isset($this->element['maxlength']) ? (int) $this->element['maxlength'] : 0;
$this->class .= ' charcounter';
}
return $return;
}
示例7: setup
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$rt = parent::setup($element, $value, $group);
$label = (string) $this->element['label'];
if (empty($label)) {
$option = JFactory::getApplication()->input->getCmd('option');
$prefix = $option;
if ($option == 'com_plugins') {
$prefix = $this->form->getData()->get('name');
}
$label = strtoupper($prefix . '_' . $this->fieldname);
}
$this->element['label'] = $label;
$this->element['description'] = $label . '_DESC';
$this->description = $label . '_DESC';
return $rt;
}
示例8: setup
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);
if ($result == true) {
// Get the client id.
$clientId = $this->element['client_id'];
if (!isset($clientId)) {
$clientName = $this->element['client'];
if (isset($clientName)) {
$client = JApplicationHelper::getClientInfo($clientName, true);
$clientId = $client->id;
}
}
if (!isset($clientId) && $this->form instanceof JForm) {
$clientId = $this->form->getValue('client_id');
}
$this->clientId = (int) $clientId;
}
return $result;
}
示例9: testSetup
/**
* Tests the name, value, id, title, lalbel property setup by JFormField::setup method
*
* @param array $expected @todo
* @param string $element @todo
* @param string $value @todo
* @param string $group @todo
*
* @return void
*
* @dataProvider getSetupData
*/
public function testSetup($expected, $element, $value, $group = null)
{
$field = new JFormFieldText();
$element = simplexml_load_string($element);
$this->assertThat($field->setup($element, $value, $group), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
// Matcher for the 'label' attribute
$matcher = array('id' => 'myId-lbl', 'tag' => 'label', 'attributes' => array('for' => 'myId', 'class' => 'hasTooltip', 'title' => '<strong>My Title</strong><br />The description.'), 'content' => 'regexp:/My Title/');
foreach ($expected as $attr => $value) {
// Label is html use assertTag()
if ($attr == 'label') {
$this->assertTag($matcher, $field->{$attr}, 'Line:' . __LINE__ . ' The ' . $attr . ' property should be computed from the XML.');
} else {
$this->assertThat($field->{$attr}, $this->equalTo($value), 'Line:' . __LINE__ . ' The ' . $attr . ' property should be computed from the XML.');
}
}
}
示例10: setup
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
$this->element['class'] = $this->element['class'] . ' color';
return $return;
}
示例11: testSetup
/**
* Tests the name, value, id, title, lalbel property setup by JFormField::setup method
*
* @param array $expected @todo
* @param string $element @todo
* @param string $value @todo
* @param string $group @todo
*
* @return void
*
* @dataProvider getSetupData
*/
public function testSetup($expected, $element, $value, $group = null)
{
$field = new JFormFieldText();
$element = simplexml_load_string($element);
$this->assertThat($field->setup($element, $value, $group), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
foreach ($expected as $attr => $value) {
$this->assertThat($field->{$attr}, $this->equalTo($value), 'Line:' . __LINE__ . ' The ' . $attr . ' property should be computed from the XML.');
}
}