Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with empty formName() and one column #347

Open
olegbaturin opened this issue May 20, 2021 · 9 comments
Open

Not working with empty formName() and one column #347

olegbaturin opened this issue May 20, 2021 · 9 comments
Labels

Comments

@olegbaturin
Copy link

Here you consider that Model::formName() returns not empty string. As a result input names look like "[attribute][index]" because here you consider that prefix can't be empty.

@unclead
Copy link
Owner

unclead commented May 20, 2021

How to reproduce the issue? In other words, post the code snippet to reproduce the issue

@olegbaturin
Copy link
Author

class MyForm extends \yii\base\Model

public function formName()
{
    return '';
}

@olegbaturin
Copy link
Author

Use example for single column. Or set the name for only one column the same as the attribute name. See this condition.

@unclead
Copy link
Owner

unclead commented May 20, 2021

Any suggestions on how to fix it? 😄 Throw an exception if form name is empty?

@olegbaturin
Copy link
Author

olegbaturin commented May 20, 2021

formName() CAN return empty string! It's just a prefix for input name. With prefix name will be "MyForm[email]" (by default), without it - "email".

Any suggestions on how to fix it?

Always return default prefix and check this condition here. So this name will be "'[' . $this->name . '][' . $index . ']'" or "'[' . $index . ']'"
I think.

@unclead unclead added the bug label Jun 26, 2021
@olegbaturin
Copy link
Author

Do you accept a PRs?

@unclead
Copy link
Owner

unclead commented Jul 8, 2021

I would rephrase - at the moment I only rely on PR 😄

@unclead
Copy link
Owner

unclead commented Jul 28, 2021

@olegbaturin so will you make a PR or it was a rhetorical question? 😄

@olegbaturin
Copy link
Author

I'll have some time to this fix in the next week or so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants