コード例 #1
0
 /**
  * Tests maxLength attribute setup by JFormFieldText::setup method
  *
  * @covers JFormField::setup
  * @covers JFormField::__get
  *
  * @return void
  */
 public function testSetup()
 {
     $field = new JFormFieldNumber();
     $element = simplexml_load_string('<field name="myName" type="text" max="60" min="1" step="2" />');
     $this->assertThat($field->setup($element, ''), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
     $this->assertThat($field->max, $this->equalTo(60), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
     $this->assertThat($field->min, $this->equalTo(1), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
     $this->assertThat($field->step, $this->equalTo(2), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
 }
コード例 #2
0
ファイル: range.php プロジェクト: eshiol/joomla-cms
 /**
  * Method to get the data to be passed to the layout for rendering.
  *
  * @return  array
  *
  * @since 3.7
  */
 protected function getLayoutData()
 {
     $data = parent::getLayoutData();
     // Initialize some field attributes.
     $extraData = array('max' => $this->max, 'min' => $this->min, 'step' => $this->step);
     return array_merge($data, $extraData);
 }
コード例 #3
0
ファイル: Numeric.php プロジェクト: akeeba/fof
 /**
  * Method to get certain otherwise inaccessible properties from the form field object.
  *
  * @param   string  $name  The property name for which to the the value.
  *
  * @return  mixed  The property value or null.
  *
  * @since   2.0
  */
 public function __get($name)
 {
     switch ($name) {
         case 'static':
             if (empty($this->static)) {
                 $this->static = $this->getStatic();
             }
             return $this->static;
             break;
         case 'repeatable':
             if (empty($this->repeatable)) {
                 $this->repeatable = $this->getRepeatable();
             }
             return $this->repeatable;
             break;
         default:
             return parent::__get($name);
     }
 }
コード例 #4
0
ファイル: meter.php プロジェクト: SysBind/joomla-cms
 /**
  * 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->width = isset($this->element['width']) ? (string) $this->element['width'] : '';
         $this->color = isset($this->element['color']) ? (string) $this->element['color'] : '';
         $active = (string) $this->element['active'];
         $this->active = $active == 'true' || $active == 'on' || $active == '1';
         $animated = (string) $this->element['animated'];
         $this->animated = !($animated == 'false' || $animated == 'off' || $animated == '0');
     }
     return $return;
 }
コード例 #5
0
ファイル: meter.php プロジェクト: eshiol/joomla-cms
 /**
  * Method to get the data to be passed to the layout for rendering.
  *
  * @return  array
  *
  * @since 3.5
  */
 protected function getLayoutData()
 {
     $data = parent::getLayoutData();
     // Initialize some field attributes.
     $extraData = array('width' => $this->width, 'color' => $this->color, 'animated' => $this->animated, 'active' => $this->active, 'max' => $this->max, 'min' => $this->min, 'step' => $this->step);
     return array_merge($data, $extraData);
 }