Adds the ability to specify a custom array name for a form field

This commit is contained in:
Sam Georges 2014-07-19 11:43:26 +10:00
parent 9f1b0415aa
commit 8bca148d31
1 changed files with 8 additions and 3 deletions

View File

@ -254,11 +254,16 @@ class FormField
/**
* Returns a value suitable for the field name property.
* @param string $arrayName Specify a custom array name
* @return string
*/
public function getName()
public function getName($arrayName = null)
{
if ($this->arrayName)
return $this->arrayName.'['.implode('][', Str::evalHtmlArray($this->columnName)).']';
if ($arrayName === null)
$arrayName = $this->arrayName;
if ($arrayName)
return $arrayName.'['.implode('][', Str::evalHtmlArray($this->columnName)).']';
else
return $this->columnName;
}