Hide H5P-Editor option in Drupal 7 using h5p_semantics_alter

Hi there,

I need to remove some H5P-Editor inputs from there. I use Drupal 7 and already implemented a hook like so:

function mod_h5p_semantics_alter(&$semantics, $machine_name, $major_version, $minor_version) {
    if ($machine_name == 'H5P.MyQuestionSet') {
        $semantics[2]->deprecated = TRUE;

At that point I tried to use the documentation from here:

Where it's suggested to remove the input option by this line actually:

$semantics[2]->field->fields[2]->deprecated = TRUE;

I could not use this code because my actual semantic differ pretty much from the way they should look like in respect to the code above. This is how the situation is:

The Semantics

So there's no such thing like "field" here. And my solution doesn't work neither.

So what's the best practise to acomplish for removal of inputs from the editor?

with best regards
Julian Strecker

icc's picture

Hi Julian! Currently, the deprecated option only works for fields with ->type = 'group'. I'm not sure in your case if you wish to hide the whole select field or if you simply wish to remove one option.

The option could be removed by doing:

// Remove 'dots' option
array_splice($semantics[2]->options, 1 ,1); 


To hide the whole field I think I would just remove it completely and rely on the default value 'textual':

// Remove 'Progress indicator' select
array_splice($semantics, 2 ,1);