简体   繁体   中英

Override a core field type in pyrocms

I am working with PyroCMS, & I have a custom built module with streams, so the form is Generated using

$this->streams->cp->entry_form('projects', 'project', 'edit', $id, true, $extra);

But the issue is that I have a field type SLUG, which generate the slug from the TITLE. But it also generate the slug from title when I am editing the Entry. I want it not to generate SLUG from TITLE when I am editing the entry. The SLUG field type add some JS code after the field which is :

$jquery = "<script>(function($) {
            $(function(){
                    pyro.generate_slug('#{$params['custom']['slug_field']}', '#{$params['form_slug']}', '{$params['custom']['space_type']}');
            });
        })(jQuery);
        </script>";

Now I want to somehow override this when I am editing the entry, I don't want the SLUG to be regenerating on editing the TITLE.

You can override the stream views. Folder structure looks like this on the module you are overriding.

You can make the field readable only on edit mode by checking the field_slug inside loop.

- views
-- admin
--- partials
---- streams
----- field_form.php

http://prntscr.com/5f7v8e

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM