This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
Sequenzia/Rails/ActionView/FormBuilder.php
2013-10-02 01:12:58 -05:00

62 lines
2.0 KiB
PHP
Executable File

<?php
namespace Rails\ActionView;
class FormBuilder
{
protected $helper;
protected $model;
protected $inputNamespace;
public function __construct($helper, $model)
{
$this->helper = $helper;
$this->model = $model;
$this->inputNamespace = \Rails::services()->get('inflector')->underscore(get_class($model));
}
public function textField($property, array $attrs = array())
{
$this->helper->setDefaultModel($this->model);
return $this->helper->textField($this->inputNamespace, $property, $attrs);
}
public function hiddenField($property, array $attrs = array())
{
$this->helper->setDefaultModel($model);
return $this->helper->hiddenField($this->inputNamespace, $property, $attrs);
}
public function passwordField($property, array $attrs = array())
{
$this->helper->setDefaultModel($model);
return $this->helper->passwordField($this->inputNamespace, $property, $attrs);
}
public function checkBox($property, array $attrs = array(), $checked_value = '1', $unchecked_value = '0')
{
$this->helper->setDefaultModel($model);
return $this->helper->passwordField($this->inputNamespace, $property, $attrs, $checked_value, $unchecked_value);
}
public function textArea($property, array $attrs = array())
{
$this->helper->setDefaultModel($model);
return $this->helper->textArea($this->inputNamespace, $property, $attrs);
}
public function select($property, $options, array $attrs = array())
{
$this->helper->setDefaultModel($model);
return $this->helper->select($this->inputNamespace, $property, $options, $attrs);
}
public function radioButton($property, $tag_value, array $attrs = array())
{
$this->helper->setDefaultModel($model);
return $this->helper->radioButton($this->inputNamespace, $property, $tag_value, $attrs);
}
}