adamwathan / form

Super basic form HTML builder, only really exists so I can pull it in for some other more useful projects.
MIT License
232 stars 117 forks source link

Leftover key transformation? #87

Closed Propaganistas closed 8 years ago

Propaganistas commented 8 years ago

Hi

When trying to debug this issue at TranslatableBootForms, I stumbled upon the following code which seems to be the underlying cause:

FormBuilder.php line 222:

public function getValueFor($name)
{
    $name = $this->transformKey($name);

    if ($this->hasOldInput()) {
        return $this->getOldInput($name);
    }

    // ...
}
//...
protected function getOldInput($name)
{
    return $this->escape($this->oldInput->getOldInput($name));
}
//...
protected function transformKey($key)
{
    return str_replace(['.', '[]', '[', ']'], ['_', '', '.', ''], $key);
}

IlluminateOldInputProvider.php line 21:

public function getOldInput($key)
{
    return $this->session->getOldInput($this->transformKey($key));
}
//...
protected function transformKey($key)
{
    return str_replace(['.', '[]', '[', ']'], ['_', '', '.', ''], $key);
}

Is there any specific reason why transformKey() is called twice throughout this process (in getValueFor() and getOldInput())? Right now, the following transformations will occur to e.g. en[title]: en[title] --> en.title --> en_title As you can see, there seems to be a superfluous transformation since en.title should be the key to search for in old input session store.

adamwathan commented 8 years ago

@JesseLeite Any thoughts on this? Looks like that was introduced in this PR: https://github.com/adamwathan/form/pull/78

jesseleite commented 8 years ago

Oh no ...git blamed! I'll look into it.

adamwathan commented 8 years ago

Fixed and tagged v0.8.3! Thanks.

Propaganistas commented 8 years ago

Thanks for the quick follow-up!