arambalakjian / DataObject-as-Page

A SilverStripe module for displaying DataObjects as Pages
53 stars 27 forks source link

Model Admin - HTMLEditorField - Forbidden to edit Link from Toolbar button #38

Closed aledbrown closed 11 years ago

aledbrown commented 11 years ago

In SS3.1.1.

To reproduce:

  1. Setup a DOAP Item with a HTMLText field or any name.
  2. Add it's HTMLEditorField to the getCMSFields.
  3. Edit or create a new Item in ModelAdmin.
  4. Enter some text into the HTML box. Select something you want to become a link.
  5. Press the Link button on the HTML editor toolbar.
  6. Blank link box pops up and you may see a "Forbidden" black status box briefly appear.

Any help appreciated.

arambalakjian commented 11 years ago

Hi Aled,

Is this new in 3.1.1, as I have a site in 3.1.0 with that exact setup and it works fine?

Aram

aledbrown commented 11 years ago

I honestly can't remember if it was an issue on 3.1.0 or not. I'll see if rolling back my Git will let me test that (after backing up my DB) as the actual DOAP has existed on this dev site I'm working on since 3.0.X so the field would be there. I just hadn't needed or thought to test adding a link into the HTML until I started filling up client content yesterday. I'll get back to you...

aledbrown commented 11 years ago

Hi Aram

I can confirm it is a 3.1.1 issue and that 3.1.0 does not "forbid" the use of the Link toolbar item on a DOAP Item HTML editor.

I couldn't find a suitable roll-back point because I've made so many changes to the site since 3.1.1 so I dropped in the 3.1.0 "cms" and "framework" directories from the download and did a dev/build flush and boom... it worked straight away.

What's the best plan? Stick with 3.1.0 for now?

Aled

arambalakjian commented 11 years ago

Hmm, ok, I wonder if this is a general Model Admin issue, rather than a DOAP. Have you got any standard Model Admin objects with an HTML editor you can test?

aledbrown commented 11 years ago

I can probably throw a few standard DataObject items I have setup as Grid Fields within the CMS at the moment into their own ModelAdmin and test.

Oh drat.. they're all just text fields and images. I'll add a HTML field to one and setup a ModelAdmin test for that DO with 3.1.0 now while that's in. Then upgrade again to 3.1.1 and see what happens.

aledbrown commented 11 years ago

Done that. I don't even need to upgrade to 3.1.1 though as adding a 'TestField' => 'HTMLText' to one of the ModelAdmin managed DOs I had throws up a Forbidden notification as soon as you press the Link toolbar icon in 3.1.0.

No amount of dev/build and full flushing makes any difference. ModelAdmin won't allow me to edit a link.

I tried adding some allowed_actions to the DO but I'm unsure what might work. I added edit and view but they made no difference either.

I think you're right that this is a ModelAdmin issue. Not specifically a DOAP issue.

aledbrown commented 11 years ago

I wish SS would throw a PHP Console error when the Forbidden notification comes up. It's useless for debugging something like this.

arambalakjian commented 11 years ago

Right, thought it might be. Prob best to submit a ticket to the core then, or email the mailing list to see if anyone else has encountered it?

arambalakjian commented 11 years ago

Yea I know, debugging is so much harder in 3.x......two steps forward....lol

aledbrown commented 11 years ago

I've not submitted any tickets to the core team before. Where do I do that?

arambalakjian commented 11 years ago

Oh sorry I think it's now all done on github, this will be framework related so post an issue in there :)

Aram

aledbrown commented 11 years ago

Thanks for your help. :) Lets hope 3.1.2 fixes a few issues when it drops.

arambalakjian commented 11 years ago

Let's hope so! :)

aledbrown commented 11 years ago

Hi Aram

I have a fix for this directly from Ingo Schommer this morning on the mailing list.

I've tested it with SS 3.1.0 and it worked. I will try to update to SS 3.1.1 later today to test it there too.

$allowed_actions needs 'EditorToolbar' adding to the array.

I put the hot fix in doap/Forms/VersionedGridFieldDetailForm.php on my copy, dev/build + flush and it worked immediately on my test field.

private static $allowed_actions = array(
    'edit',
    'view',
    'ItemEditForm',
    'EditorToolbar'
);

Best Regards Aled

arambalakjian commented 11 years ago

Great thanks Aled, I'll get this fixed

aledbrown commented 11 years ago

I think it should also go in DataObjectAsPageAdmin.php too.

It was working for a bit... then I found another DOAP editor where it wasn't working.

I added the fix to the subclass of ModelAdmin and it's working again.

I'm working on this site all week so I'll be looking out for issues with this fix.

arambalakjian commented 11 years ago

Hi Aled,

The issue is that if you DOAP is not versioned then it won't be using the custom gridfield and so you will still have the issue with the standard gridfield.

I have added the fix on here for versioned, but you'll need to keep your fix in the ModelAdmin class for now until the core is fixed.

Aram

arambalakjian commented 11 years ago

Hi Aled,

Just commited this fix, and also removed the overloaded EditorToolbar function from DataObjectAsPageAdmin that may have bene causing the problems.

bear in mind that I also discovered that in 3.1.1 ModelAdmin won't show Draft records, so for now this module is 3.1.0 only.

Aram