Omeka Classic - Modules ' Add input '

Hi , i’m wondering how can i delete the button " Add input " but just from one field , i mean not all of them , just the button from “Coverage” or "Title " , this part is on / Collections / Add colecction / ( i know that these fields are common to items and exhibits ) , how can i select wich “button” delete and wich one not to

i found the .php file that delete ALL the fields , but i don’t want delete all of them

With a plugin and the ElementForm filter you can do this to a specific element for a specific record type (Item, Collection, etc.).

Should i add

class MyPlugin extends Omeka_Plugin_AbstractPlugin
{

protected $_filters = array('shortenSubjectField' => array('ElementInput', 'Item', 'Dublin Core', 'Title'));

public function shortenSubjectField($components, $args)
{
    $components['input'] = get_view()->formText($args['input_name_stem'] . '[text]', $args['value']);
    return $components;
}

}

to Elementform.php file? , or in other one , cause the link says a class from a plugin , must i install a plugin ? , or just find another file ?

i was trying to code this part from “Elementform.php” , what i expected is that if the label is Subject i would be able to add an input and if is another one , equal to 0 , from that way i could just add input from subject , but it doesn’t work , how could i make this , is it possible in this code ?
$labelComponent = $this->_getLabelComponent();
** if ( $ labelComponent = ‘Subject’){**
** $inputsComponent = $this->_getInputsComponent($extraFieldCount);}**
** else{ $inputsComponent = 0 }**
** $descriptionComponent = $this->_getDescriptionComponent();**
** $commentComponent = $this->getCommentComponent();**
** $addInputComponent = $this->view->formButton('add_element
’ . $this->_element[‘id’],**
** __(‘Add Input’), array(‘class’ => ‘add-element’));**
** $components = array(**
** ‘label’ => $labelComponent,**
** ‘inputs’ => $inputsComponent,**
** ‘description’ => $descriptionComponent,**
** ‘comment’ => $commentComponent,**
** ‘add_input’ => $addInputComponent,**
** ‘html’ => null**

So, to use the filter as I suggested, you’d need to create a plugin. The code shown on that page is just an example and won’t actually do what you’re trying to do here, though.

The plugin you’d create could be just about as simple as that example, though.

The strategy you mentioned in another thread would also work: editing ElementForm.php directly… you just got the details a little bit wrong. You’d want to test against $element->name, not $labelComponent. In general, though, I don’t recommend modifying the core like this as it leads to problems down the line when you want to upgrade but maintain your changes.

1 Like

This topic was automatically closed 250 days after the last reply. New replies are no longer allowed.