You are here

protected function AvailabilityCalendarStylesFormBuilder::colorField in Availability Calendars 7.3

Same name and namespace in other branches
  1. 7.5 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 $css_property 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 return the fieldset for the states styles.
AvailabilityCalendarStylesFormBuilder::fieldsetTable in ./availability_calendar.styles.inc
Helper method to return the fieldset for the table styles.

File

./availability_calendar.styles.inc, line 277

Class

AvailabilityCalendarStylesFormBuilder

Code

protected function colorField($cssProperty) {
  if (is_array($cssProperty)) {
    list($fieldName, $cssProperty) = each($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' => '#',
  );
}