Skip to content

Add selectMonth, selectYear, selectRange methods to FormBuilder#1529

Closed
JeffreyWay wants to merge 3 commits intolaravel:masterfrom
JeffreyWay:master
Closed

Add selectMonth, selectYear, selectRange methods to FormBuilder#1529
JeffreyWay wants to merge 3 commits intolaravel:masterfrom
JeffreyWay:master

Conversation

@JeffreyWay
Copy link
Copy Markdown
Contributor

For issue #1502.

Haven't yet done localization.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP 5.3 please, Jeffrey :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gah. :) Dang muscle memory.

@taylorotwell
Copy link
Copy Markdown
Member

Ported this to 4.0 branch. Hopefully you still love me :)

@JeffreyWay
Copy link
Copy Markdown
Contributor Author

haha.

Just spent five minutes looking for an old man shaking his fist meme...but gave up. So take that.

@JosephSilber
Copy link
Copy Markdown
Contributor

As it stands, the selectYear method serves no purpose whatsoever; it has the exact same signature as selectRange, with the same semantics.

I think the following would be much better:

public function selectYear($name, $years = 6, $selected = null, $options = array())
{
    $year = date('Y');

    return $this->selectRange($name, $year, $year + $years, $selected, $options);
}

Its usage would then be much simpler, namely:

echo Form::selectYear('year');

which would output the following:

<select name="year">
    <option value="2013">2013</option>
    <option value="2014">2014</option>
    <option value="2015">2015</option>
    <option value="2016">2016</option>
    <option value="2017">2017</option>
    <option value="2018">2018</option>
</select>

If one requires the starting year to be different than the current year, selectRange is still perfectly capable of handling that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants