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/lib/Rails/ActionView/FormBuilder.php

62 lines
2.0 KiB
PHP
Raw Normal View History

2013-10-02 18:14:53 +02:00
<?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);
}
}