Mandatory fields in database activity

Mandatory fields in database activity

by Stefan Lippke -
Number of replies: 18
Hi there,

is there any way to make some or all fields of a dataset mandatory?

Thanks for your help

Stefan
Average of ratings: -
In reply to Stefan Lippke

Re: Mandatory fields in database activity

by Jean-Luc Delghust -
I was wondering the same thing. Couldn't find the answer in the forums...Anyone?
In reply to Jean-Luc Delghust

Re: Mandatory fields in database activity

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi,

Unfortunately it's not currently possible to make certain fields mandatory. However, this feature has been requested previously - MDL-5583. Please vote for the issue if you'd like it to be fixed (you'll need a tracker account) to help developers determine development priorities.
Average of ratings: Useful (2)
In reply to Helen Foster

Re: Mandatory fields in database activity

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
I like seeing that folks are voting on the issues in the tracker. It is very helpful to know what features people really want to see. Just a quick note to remind folks that MDL-11400 is related to MDL-5583. In a sense they are the same issue; however, actually getting it to work is going to require some heavy duty thinking about how the forms are built. It probably will not happen until 2.0 but I have it on my list of projects to play with when I get free moment. At the moment, I am trying to finish off this academic semester. Peace - Anthony
In reply to Anthony Borrow

Re: Mandatory fields in database activity

by Robert Brenstein -
Thinking and effort, yes, but really so heavy duty thinking? Several other modules have such a functionality. They simply display the same input form with an error msg. Profile form might be a good example to follow.
In reply to Robert Brenstein

Re: Mandatory fields in database activity

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Robert - I know, my initial reaction was very similar and I thought that it should be trivial and easily copied from other areas, etc. It has been over a month since I looked at the code so it is a bit of a distant memory for me in the midst of my theology studies. I forget what the difference was but it unfortunately will require more thinking and effort than one would initially suspect. I'll make a point over the Christmas break to go back and see if I can make any progress with a functional patch. Peace - Anthony
In reply to Anthony Borrow

Re: Mandatory fields in database activity

by Emma Yench -

Hi All

Can anyone tell me if this works yet in Moodle 2.0? I can't find a way to specify mandatory fields. If there's no easy tick box, does anyone know whether adding some Javascript in the Javascript template will do the trick, and if so, what i should be adding?

thanks!

Emma

In reply to Emma Yench

Re: Mandatory fields in database activity

by Paul Young -

You should be able to do this easily in dataform developed by Itamar Tzadok. Please note that it is still a beta version. 

In reply to Emma Yench

Re: Mandatory fields in database activity

by Itamar Tzadok -

Yes, with most of the fields in the dataform you can add to the view template a tag [[*fieldname] ] to make the field required when adding/editing an entry. The plan is to get the dataform over beta by the end of august (unit tests are already working but we need more).

You can also use javascript but this is not foolproof as the user can turn the javascript off. If you use javascript you can set the template to hide or disable the input fields by css and let the javascript enable them. This way turning off the javascript would prevent entering the form. That would still not be foolproof but it may be enough for your purpose.

smile

In reply to Itamar Tzadok

Re: Mandatory fields in database activity

by Federica Marra -

Hi!

Is there someone that can explain me how to set up the mandatory fields?
I don't understand very well neither the procedure with the *fieldname neither the one in MDL-21969.
mixed

Thanks!

In reply to Federica Marra

Re: Mandatory fields in database activity

by Itamar Tzadok -

The mandatory fields in the Database activity will be available from 2.9. You will set the field as required in the field configuration.

The mandatory fields by * in the field pattern is not in the Database activity but in the Dataform activity. So, if you are using the Database, this option is not available for you.

smile

Average of ratings: Useful (2)
In reply to Itamar Tzadok

Re: Mandatory fields in database activity

by Hartmut Scherer -

Thank you, Itamar. I just tried a Database activity in a test version of Moodle 2.9dev and it works. Great!

With kind regards,

Hartmut

In reply to Itamar Tzadok

Re: Mandatory fields in database activity

by Nils Ratnaweera -
Hey Itamar,

I'm using Moodle 3.0.2 (Build: 20160111) but I see no place where I could set certain fields manatory. Is this option implemented yet?

With best regards,

Nils

In reply to Nils Ratnaweera

Re: Mandatory fields in database activity

by Itamar Tzadok -

There is a checkbox 'Required field' in the configuration form of the fields. Not sure why you can't see it. Can you post a screenshot? smile

In reply to Itamar Tzadok

Re: Mandatory fields in database activity

by Nils Ratnaweera -
Ok strange.. I've uploaded a screenshot from one of the configuraitons of one of my fields..
Attachment Fields.png