Feature Request #2747
Add a 'target' feature to Form::open()
| Status: | Closed | Start date: | 03/26/2010 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | Core | |||
| Target version: | v3.1.0 | |||
| Resolution: | invalid | Points: |
Description
I think it would be nice to be able to define an target when opening a form tag, which if set would be added to the action attribute, so when submitting the form the page would jump to this target. This is very useful for two things:
- there's no need to define the whole url for the action attribute every time when I want to do something like this, which leads to less code
- it would lead to better usuability on pages, because this way the user's attention can be focused on errors or notifications or other important things
I think this modification should be enough:
public static function open($action = NULL, array $attributes = NULL, $id = NULL)
{
if ($action === NULL)
{
// Use the current URI
$action = Request::instance()->uri;
}
if ($action === '')
{
// Use only the base URI
$action = Kohana::$base_url;
}
elseif (strpos($action, '://') === FALSE)
{
// Make the URI absolute
$action = URL::site($action);
}
// Add the form action to the attributes
if ($id === NULL)
{
$attributes['action'] = $action;
}
else
{
$attributes['action'] = $action . '#' . $id;
}
// Only accept the default character set
$attributes['accept-charset'] = Kohana::$charset;
if ( ! isset($attributes['method']))
{
// Use POST method
$attributes['method'] = 'post';
}
return '<form'.HTML::attributes($attributes).'>';
}
History
Updated by Woody Gilk about 2 years ago
- Category set to Core
- Target version set to v3.1.0
Updated by Jeremy Bush over 1 year ago
- Status changed from New to Closed
- Resolution set to invalid
You should be able to use form::open('foo/bar#baz').