Override a core field type in pyrocms

285 views Asked by At

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.

1

There are 1 answers

0
kamal On

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