Add new fbvFormArea in management

Hello Everybody.

I need add new Forms in my ojs 3 (management/settings) because I had this implemented in Ojs 2.4.8 and I’m making the change over 3.
image
I add Form in

  • templates/controllers/tab/settings/masthead/form/mastheadForm.tpl

      {fbvFormArea id="mastheadFacultaTematica"}
      {fbvFormSection label="manager.setup.facultad" for="facultad" description="manager.setup.facultadDescription"}
      	{fbvElement type="text" name="facultad" id="facultad" value=$facultad maxlength="255"}
      {/fbvFormSection}{/fbvFormArea}
    

add in controllers/tab/settings/masthead/form/MastheadForm.inc.php

function __construct($wizardMode = false) {
	$settings = array(
	    'facultad' => 'string',
		'name' => 'string',
		'acronym' => 'string',...

and

    $this->addCheck(new FormValidatorLocale($this, 'facultad', 'required',manager.setup.form.journalFacultadRequired'));

and

function getLocaleFieldNames() {
	return array('facultad','name', 'acronym', ...

My question is where to add my functions:

	 * Return the localized facultad
 * @return string
 */
function getLocalizedFacultad() {
	return $this->getLocalizedData('facultad');
}

/**
 * Get facultad
 * @param $locale
 * @return string
 */
function getFacultad($locale) {
	return $this->getData('facultad', $locale);
}

/**
 * Set facultad
 * @param $discipline string
 * @param $locale
 */
function setFacultad($facultad, $locale) {
	return $this->setData('facultad', $facultad, $locale);
}	

I should add them in /lib/pkp/classes/submission/Submission.inc.php ? What other files should I modify?

Regards
Cristian

Hi @cristianviza,

Are you trying to add settings that get attached to the journal, or the individual submission?

Regards,
Alec Smecher
Public Knowledge Project Team

is a feature that is only associated with each journal, not individual submission. We associate each journal with a facultad.

That makes me assume that I should not add them in
/lib/pkp/classes/submission/Submission.inc.php but I don´t know where add.

Hi @cristianviza,

That’s right, no need to edit Submission.inc.php – or indeed to add functions like getFacultad at all. You can access journal settings by using the getSetting function, e.g.:

$journal->getSetting('facultad')

Regards,
Alec Smecher
Public Knowledge Project Team

Hello @asmecher

getSetting It’s enough? in what file should I add it? a set function is not necessary? because this web page is CRUD. I want to modify/charge the value and save.
Now form area not load value stored in database (table: journal_settings )and not save changes write in form facultad (when I reload the page they are not stored).

For example for “journal name” (picture above) which is the file that has the function that assigns the content to the variable “publisherInstitution”. where that variable is assigned?

In my database the value stored in journal_settings table. Example:

select * from journal_settings where journal_id=42 and setting_name='facultad';
-[ RECORD 1 ]-+------------------------------------------
journal_id    | 42
locale        | es_ES
setting_name  | facultad
setting_value | Facultad de Ciencias Jurídicas y Sociales
setting_type  | string

Regads

Hi @cristianviza,

In the form class (e.g. MastheadForm.inc.php), listing the setting name in the constructor (and, for localized content, getLocaleFieldNames) function is enough to cause it to be assigned to the template, saved with the form, etc.

Regards,
Alec Smecher
Public Knowledge Project Team

ok. I understand :slight_smile: . Take the full list “settings” from the constructor and should save everything settings.

but I add “facultad” in settings = array (controllers/tab/settings/masthead/form/ MastheadForm.inc.php) and formArea in (templates/controllers/tab/settings/masthead/form/ mastheadForm.tpl) similar to is defined for ‘name’ or ‘publisherInstitution’. it would have to work but not . When I re-load page not load info in formArea facultad or I modify and save but not save notting. $facultad is not set.

I need to write $journal->getSetting(‘facultad’) somewhere to work ?

Regards
Cristian

Hi @cristianviza,

It looks like you need to set multilingual=true in your {fbvFormElement ...} for that control.

Regards,
Alec Smecher
Public Knowledge Project Team

Yes @asmecher . Sloved. Thanks :smiley: .

I observe it is much simpler and more orderly for the development this version. Congratulations. To do the same in 2.4.x I had to modify more elements.

Regards
Cristian

1 Like