<commit_before><?php namespace Rdehnhardt\Html;

use Collective\Html\FormBuilder as IlluminateFormBuilder;

class FormBuilder extends IlluminateFormBuilder
{
    /**
     * An array containing the currently opened form groups.
     *
     * @var array
     */
    protected $groupStack = array();

    /**
     * Open a new form group.
     *
     * @param  string $name
     * @param  mixed $label
     * @param  array $options
     * @return string
     */
    public function openGroup($name, $label = null, $options = array())
    {
        $options = $this->appendClassToOptions('form-group', $options);

        // Append the name of the group to the groupStack.
        $this->groupStack[] = $name;

        if ($this->hasErrors($name)) {
            // If the form element with the given name has any errors,
            // apply the 'has-error' class to the group.
            $options = $this->appendClassToOptions('has-error', $options);
        }

        // If a label is given, we set it up here. Otherwise, we will just
        // set it to an empty string.
        $label = $label ? $this->label($name, $label) : '';

        return '<div' . $this->html->attributes($options) . '>' . $label;
    }

    /**
     * Close out the last opened form group.
     *
     * @return string
     */
    public function closeGroup()
    {
        // Get the last added name from the groupStack and
        // remove it from the array.
        $name = array_pop($this->groupStack);

        // Get the formatted errors for this form group.
        $errors = $this->getFormattedErrors($name);

        // Append the errors to the group and close it out.
        return $errors . '</div>';
    }

    /**
     * Open a new form actions.
     *
     * @param  array $options
     * @return string
     */
    public function openFormActions($options = array())
    {
        $options = $this->appendClassToOptions('form-actions', $options);

        return '<div' . $this->html->attributes($options) . '>';
    }

    /**
     * Close out the last opened form group.
     *
     * @return string
     */
    public function closeFormActions()
    {
        return '</div>';
    }

    /**
     * Create a form input field.
     *
     * @param  string $type
     * @param  string $name
     * @param  string $value
     * @param  array $options
     * @return string
     */
    public function input($type, $name, $value = null, $options = array())
    {
        if ($type != 'submit') {
            $options = $this->appendClassToOptions('form-control', $options);
        }

        // Call the parent input method so that Laravel can handle
        // the rest of the input set up.
        return parent::input($type, $name, $value, $options);
    }

    /**
     * Create a select box field.
     *
     * @param  string $name
     * @param  array $list
     * @param  string $selected
     * @param array $selectAttributes
     * @param array $optionsAttributes
     * @return string
     */
    public function select($name, $list = [], $selected = null, array $selectAttributes = [], array $optionsAttributes = [])
    {
        $selectAttributes = $this->appendClassToOptions('form-control', $selectAttributes);

        // Call the parent select method so that Laravel can handle
        // the rest of the select set up.
        return parent::select($name, $list, $selected, $selectAttributes, $optionsAttributes);
    }

    /**
     * Create a select box field.
     * @param $name
     * @param $class
     * @param array $first
     * @param array $columns
     * @param null $selected
     * @param array $options
     * @return \Illuminate\Support\HtmlString
     */
    public function lookup($name, $class, array $first = [], array $columns = [], $selected = null, $options = array())
    {
        $options = $this->appendClassToOptions('form-control', $options);

        if (!array_key_exists('label', $columns)) {
            $columns['label'] = 'title';
        }

        if (!array_key_exists('value', $columns)) {
            $columns['value'] = 'id';
        }

        $model = new $class;<commit_msg>fix method select compatible with collective<commit_after><?php namespace Rdehnhardt\Html;

use Collective\Html\FormBuilder as IlluminateFormBuilder;

class FormBuilder extends IlluminateFormBuilder
{
    /**
     * An array containing the currently opened form groups.
     *
     * @var array
     */
    protected $groupStack = array();

    /**
     * Open a new form group.
     *
     * @param  string $name
     * @param  mixed $label
     * @param  array $options
     * @return string
     */
    public function openGroup($name, $label = null, $options = array())
    {
        $options = $this->appendClassToOptions('form-group', $options);

        // Append the name of the group to the groupStack.
        $this->groupStack[] = $name;

        if ($this->hasErrors($name)) {
            // If the form element with the given name has any errors,
            // apply the 'has-error' class to the group.
            $options = $this->appendClassToOptions('has-error', $options);
        }

        // If a label is given, we set it up here. Otherwise, we will just
        // set it to an empty string.
        $label = $label ? $this->label($name, $label) : '';

        return '<div' . $this->html->attributes($options) . '>' . $label;
    }

    /**
     * Close out the last opened form group.
     *
     * @return string
     */
    public function closeGroup()
    {
        // Get the last added name from the groupStack and
        // remove it from the array.
        $name = array_pop($this->groupStack);

        // Get the formatted errors for this form group.
        $errors = $this->getFormattedErrors($name);

        // Append the errors to the group and close it out.
        return $errors . '</div>';
    }

    /**
     * Open a new form actions.
     *
     * @param  array $options
     * @return string
     */
    public function openFormActions($options = array())
    {
        $options = $this->appendClassToOptions('form-actions', $options);

        return '<div' . $this->html->attributes($options) . '>';
    }

    /**
     * Close out the last opened form group.
     *
     * @return string
     */
    public function closeFormActions()
    {
        return '</div>';
    }

    /**
     * Create a form input field.
     *
     * @param  string $type
     * @param  string $name
     * @param  string $value
     * @param  array $options
     * @return string
     */
    public function input($type, $name, $value = null, $options = array())
    {
        if ($type != 'submit') {
            $options = $this->appendClassToOptions('form-control', $options);
        }

        // Call the parent input method so that Laravel can handle
        // the rest of the input set up.
        return parent::input($type, $name, $value, $options);
    }

    /**
     * Create a select box field.
     *
     * @param  string $name
     * @param  array $list
     * @param  string $selected
     * @param array $selectAttributes
     * @param array $optionsAttributes
     * @param array $optgroupsAttributes
     * @return string
     */
    public function select($name, $list = [], $selected = null, array $selectAttributes = [], array $optionsAttributes = [], array $optgroupsAttributes = [])
    {
        $selectAttributes = $this->appendClassToOptions('form-control', $selectAttributes);

        // Call the parent select method so that Laravel can handle
        // the rest of the select set up.
        return parent::select($name, $list, $selected, $selectAttributes, $optionsAttributes);
    }

    /**
     * Create a select box field.
     * @param $name
     * @param $class
     * @param array $first
     * @param array $columns
     * @param null $selected
     * @param array $options
     * @return \Illuminate\Support\HtmlString
     */
    public function lookup($name, $class, array $first = [], array $columns = [], $selected = null, $options = array())
    {
        $options = $this->appendClassToOptions('form-control', $options);

        if (!array_key_exists('label', $columns)) {
            $columns['label'] = 'title';
        }

        if (!array_key_exists('value', $columns)) {
            $columns['value'] = 'id';
        }

        $model = new $class;
{'fraction_non_alphanumeric': 0.13119847054606285, 'fraction_numerical': 0.0, 'mean_word_length': 2.1149981391886863, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '191492', 'n_tokens_mistral': 2333, 'n_tokens_neox': 2307, 'n_words': 731}