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
Better name for "Model::formName()" #284
Comments
Agree and I think I like getInputName() best |
I think
|
If I may chime in, I don't think that a model class (being an entity, normally) should be aware of the surrounding context/environment. It shouldn't know about things like HTML forms, it should be neutral to such things. Having the model class generate a name for the outside context, instead of having some utility/whatever do it, is like doing the reverse of DI, not clean. In Yii 1.1 terms I think the method at hand would belong in CActiveForm. Not sure what that translates to in Yii 2 terms, but preferrably not the model class :) |
I think I missed the point of the actual discussion. I agree with @klimov-paul that the method should at least be named so that it isn't form specific. A name that indicates it returns some kind of "system" name would be appropriate, like there are in CHtml today. |
Possible variations:
|
modelId() ? |
Sounds to return value, which is unique for each class instance. |
rawtaz has good point, i like modelName() |
If this was to be put in another class (equivalent to CActiveForm or whatever), there wouldn't be a problem coming up with a good name. The fact that this is the case now say something :-) |
Yeah. I don't agree with it. |
you mean each instance of the same class? why would it mean that? it returns a unique ID of a specific class, there are no two different class with same Id (name)... $model->id() or $model->getId(), $model->getModelId() variations are used in Yii frequently |
@mdomba, after some thought, I have nothing against "modelId()". It could be used. |
I think |
i also think |
Note that "form" doesn't necessarily refer to HTML forms. The term can be used in API as well. It is usually connected with user inputs, regardless of how it is presented. |
Resolution: no further actions. |
Forked from #236
Method name “yii\base\Model::getFormName()” sounds confusing. For me words “form name” associates with “<form name=”form-name”>”.
I suppose this method should be named otherwise, like:
The text was updated successfully, but these errors were encountered: