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

Extrafield Hooks / Customization #1521

Open
Kilandor opened this issue Jun 13, 2016 · 2 comments
Open

Extrafield Hooks / Customization #1521

Kilandor opened this issue Jun 13, 2016 · 2 comments

Comments

@Kilandor
Copy link
Member

Kilandor commented Jun 13, 2016

The problem is you can not fully modify or alter extrafields when they are being added/updated.
The following hooks exist before the call to the add/update functions are created admin.extrafields.add and admin.extrafields.update

The issue is that all of the functionality of the add/update functions are not exposed.
This is the core function

function cot_extrafield_update($location, $oldname, $name, $type, $html='', $variants='', $default='', $required=0, $parse='HTML', $description='', $params = '', $enabled = 1, $customtype = '')

In extrafields.add we have the following. Which is missing any options to set the custom type. As a work around for adding, it is possible to empty field_name and field_type to prevent adding the extrafield here and issue the function call yourself with a hook.

cot_extrafield_add($n, $field['field_name'], $field['field_type'], $field['field_html'], $field['field_variants'], $field['field_default'], $field['field_required'], $field['field_parse'], $field['field_description'], $field['field_params'], $field['field_enabled'], $field['field_noalter'])

In extrafields.update we have the following. Again we are lacking access to all the parameters. However without causing the function to detect an error and stop it is not easy to modify this.

$fieldresult = cot_extrafield_update($n, $k, $field['field_name'], $field['field_type'], $field['field_html'], $field['field_variants'], $field['field_default'], $field['field_required'], $field['field_parse'], $field['field_description'], $field['field_params'], $field['field_enabled']);

I think we need to either expose access to the extra options so they can be modified, Or create new hooks inside of the function calls. I think hooking inside of the functions is not needed honestly, and we could just add variable's to the functions to allow passing data.

The case example here is a plugin I am creating, which extends functionality. I want to have a extrafield labeled as file for uploading, however I want the SQL type to be TEXT because I need room for extra storage of data.

@Kilandor
Copy link
Member Author

An alternative would be to match and move the hook for extrafields.update outside of the IF check so it functions the same as extrafields.add Then you can override the core modifying the field.

Of course adding an override variable to prevent these operations to the IF check would probably be the easiest and best solution. Along with moving the hook.

@macik
Copy link
Member

macik commented Jun 24, 2016

It's a good point.
Can you make a pull request with this fix?

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

No branches or pull requests

2 participants