You are here

protected function AvailabilityCalendarStylesFormBuilder::colorField in Availability Calendars 7.5

Same name and namespace in other branches
  1. 7.3 availability_calendar.styles.inc \AvailabilityCalendarStylesFormBuilder::colorField()
  2. 7.4 availability_calendar.styles.inc \AvailabilityCalendarStylesFormBuilder::colorField()

Helper method to add a color field to a given fieldset.

By extracting this, we get standardized settings and handling for color fields. E.g: for now only color codes are allowed, but this function could add support for other notations (http://www.w3.org/TR/CSS21/syndata.html#color-units) or a color picker.

Parameters

string|array $cssProperty: The name of the css color property to add. If this is not the same as the form field name, pass in an array with 1 element: <field name> => <css property>.

2 calls to AvailabilityCalendarStylesFormBuilder::colorField()
AvailabilityCalendarStylesFormBuilder::fieldsetStates in ./availability_calendar.styles.inc
Helper method to create the fieldset for the states styles.
AvailabilityCalendarStylesFormBuilder::fieldsetTable in ./availability_calendar.styles.inc
Helper method to create the fieldset for the table styles.

File

./availability_calendar.styles.inc, line 270

Class

AvailabilityCalendarStylesFormBuilder

Code

protected function colorField($cssProperty) {
  if (is_array($cssProperty)) {
    $fieldName = key($cssProperty);
    $cssProperty = current($cssProperty);
  }
  else {
    $fieldName = $cssProperty;
  }
  $this->form[$this->currentFieldset][$fieldName] = array(
    '#type' => 'textfield',
    '#title' => $cssProperty,
    '#default_value' => $this
      ->getStyle($fieldName),
    '#size' => 8,
    '#maxlength' => 7,
    '#field_prefix' => '#',
  );
}