TypeRocket / core

TypeRocket core source files where all the magic lives.
https://typerocket.com
36 stars 21 forks source link

Database fields in camelCase not supported inside tr_form #73

Closed tomislav13 closed 4 years ago

tomislav13 commented 4 years ago

Regards, I am using custom resources ie custom tables, and in my edit.php form I have camelCase field like this: echo $form->text('myField') but it looks like this field's value is not populated (in form). In my add.php form, I found that the field are converted to lowercase and knowing that I just fetch myfield and this works. Update: I found temporary solution, where I need to manually convert those fields, but this is not very practical:

        $model = (new Entity)->findOrDie($id);
        $model->myfield = $model->myField;
        $form = tr_form($this->modelSlug, 'update', null, $model);

Can you implement camelCase support here? Also, can I suggest that you improve the docs with tr_form's 4th argument? Because this doesn't work: $form = tr_form($this->modelSlug, 'update', $id); but this does: $form = tr_form($this->modelSlug, 'update', null, $model); and this also doesn't work: $form = tr_form($this->modelSlug, 'update', $id, $model);

kevindees commented 4 years ago

Hey @tomislav13

Unfortunately, there is no plan to support camelCase fields right now. TypeRocket enforces snake_case for consistency with the WP standard https://codex.wordpress.org/Database_Description (though the old table fields on early WP do not follow that pattern). Also, using snake_case enables better compatibility with third party plugins.

Thanks, Kevin

tomislav13 commented 4 years ago

Thanks for quick response, I think I will then use the snake_case...