/**
   * Returns HTML code for a column in edit mode.
   *
   * @param ColumnMap $column  The column name
   * @param array  $params  The parameters
   *
   * @return string HTML code
   */
  public function getCrudColumnEditTag($column, $params = array())
  {
    $type = $column->getCreoleType();

    if ($column->isForeignKey())
    {
      if (!$column->isNotNull() && !isset($params['include_blank']))
      {
        $params['include_blank'] = true;
      }
      return $this->getPHPObjectHelper('select_tag', $column, $params, array('related_class' => $this->getRelatedClassName($column)));
    }
    else if ($type == CreoleTypes::DATE)
    {
      // rich=false not yet implemented
      return $this->getPHPObjectHelper('input_date_tag', $column, $params, array('rich' => true));
    }
    else if ($type == CreoleTypes::TIMESTAMP)
    {
      // rich=false not yet implemented
      return $this->getPHPObjectHelper('input_date_tag', $column, $params, array('rich' => true, 'withtime' => true));
    }
    else if ($type == CreoleTypes::BOOLEAN)
    {
      return $this->getPHPObjectHelper('checkbox_tag', $column, $params);
    }
    else if ($type == CreoleTypes::CHAR || $type == CreoleTypes::VARCHAR)
    {
      $fieldMin = $this->getParameterValue('defaults.edit.char_min', 20);
      $fieldMax = $this->getParameterValue('defaults.edit.char_max', 80);
      $size = ($column->getSize() > $fieldMin ? ($column->getSize() < $fieldMax ? $column->getSize() : $fieldMax) : $fieldMin);
      return $this->getPHPObjectHelper('input_tag', $column, $params, array('size' => $size));
    }
    else if ($type == CreoleTypes::INTEGER || $type == CreoleTypes::TINYINT || $type == CreoleTypes::SMALLINT || $type == CreoleTypes::BIGINT)
    {
      $size = $this->getParameterValue('defaults.edit.int_size', 7);
      return $this->getPHPObjectHelper('input_tag', $column, $params, array('size' => $size));
    }
    else if ($type == CreoleTypes::FLOAT || $type == CreoleTypes::DOUBLE || $type == CreoleTypes::DECIMAL || $type == CreoleTypes::NUMERIC || $type == CreoleTypes::REAL)
    {
      $size = $this->getParameterValue('defaults.edit.float_size', 7);
      return $this->getPHPObjectHelper('input_tag', $column, $params, array('size' => $size));
    }
    else if ($type == CreoleTypes::TEXT || $type == CreoleTypes::LONGVARCHAR)
    {
      $size = $this->getParameterValue('defaults.edit.text_size', '80x5');
      return $this->getPHPObjectHelper('textarea_tag', $column, $params, array('size' => $size));
    }
    else
    {
      return $this->getPHPObjectHelper('input_tag', $column, $params, array('disabled' => true));
    }
  }
 /**
  * Returns a PHP string representing options to pass to a widget for a given column.
  *
  * @param  ColumnMap $column  A ColumnMap object
  *
  * @return string    The options to pass to the widget as a PHP string
  */
 public function getWidgetOptionsForColumn(ColumnMap $column)
 {
     $options = array();
     $withEmpty = $column->isNotNull() && !$column->isForeignKey() ? array("'with_empty' => false") : array();
     switch ($column->getType()) {
         case PropelColumnTypes::BOOLEAN:
             $options[] = "'choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no')";
             break;
         case PropelColumnTypes::DATE:
         case PropelColumnTypes::TIME:
         case PropelColumnTypes::TIMESTAMP:
             $options[] = "'from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate()";
             $options = array_merge($options, $withEmpty);
             break;
         default:
             $options = array_merge($options, $withEmpty);
     }
     if ($column->isForeignKey()) {
         $options[] = sprintf('\'model\' => \'%s\', \'add_empty\' => true', $this->getForeignTable($column)->getClassname());
         $refColumn = $this->getForeignTable($column)->getColumn($column->getRelatedColumnName());
         if (!$refColumn->isPrimaryKey()) {
             $options[] = sprintf('\'key_method\' => \'get%s\'', $refColumn->getPhpName());
         }
     }
     return count($options) ? sprintf('array(%s)', implode(', ', $options)) : '';
 }
 /**
  * Returns a PHP string representing options to pass to a widget for a given column.
  *
  * @param  ColumnMap $column  A ColumnMap object
  *
  * @return string    The options to pass to the widget as a PHP string
  */
 public function getWidgetOptionsForColumn(ColumnMap $column)
 {
     $options = array();
     $withEmpty = sprintf('\'with_empty\' => %s', $column->isNotNull() ? 'false' : 'true');
     switch ($column->getType()) {
         case PropelColumnTypes::BOOLEAN:
             $options[] = "'choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no')";
             break;
         case PropelColumnTypes::DATE:
         case PropelColumnTypes::TIME:
         case PropelColumnTypes::TIMESTAMP:
             $options[] = "'from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate()";
             $options[] = $withEmpty;
             break;
     }
     if ($column->isForeignKey()) {
         $options[] = sprintf('\'model\' => \'%s\', \'add_empty\' => true', $this->getForeignTable($column)->getClassname());
     }
     return count($options) ? sprintf('array(%s)', implode(', ', $options)) : '';
 }