how to mark/check a checkbox in Moodle - moodle

I have a lot of checkboxes and their names are generated with the help of the resource id they are associated with, which in turn is fetched from the database.
$mform->addElement('checkbox', 'incres'.$coursename.$sec->section.$record3->instance);
The second parameter is the name of the checkbox.
I need to know how to mark this checkbox as checked.I have a feeling this can be done by the setDefault method but I cant figure out how. I tried
$mform->setDefault('reqdres'.$coursename.$sec->section.$record3->instance,1);
But that doesnt work. I dont wish to use Javascript or the advancecheckbox element for this since that will require me doing a lot of changes in other dependant modules

Did you try using the Advanced Check Box? $mform->setDefault() should work with this.

Related

Prefilled notes of Class attributes in Enterprise architect

is there a way to have prefilled attributes notes in enterprise architect?
It should be something like this scenario:
1) I create new attribute
2) Enterprise architect prefill note of attribute with predefined text
Something like template for attributes.
Thank you for any advice
I know this won't help directly this question.
Anyways you can achieve it through an external addin.
All you need to do is handle the EA_OnPreNewAttribute and EA_OnPostNewAttribute broadcast events .
This isn't quite what you're after but it is possible to create an Attribute stereotype in a Profile and add to this a Tag with an initial value set to what ever you want. When you create an attribute with this stereotype, this means your predefined text would appear in a tag-value for the attribute rather than the note. Not ideal, but might work for you.
You could also have a go at writing some JavaScript to do this as well (under Scripting in EA). You'd have to use the JS to navigate the repository structure, find the attributes in question, and update their note. I don't believe you can attach a script to a UI event, so I think you'd be stuck running this post-hoc rather than having the note auto-populate on attribute creation.

Instantsearch filter by custom function

Due to certain limitations I am not able to index categories and subcategories so I need a way to be able to filter a list of manually created items. It's actually a two part thing:
1: I am filtering the visible results via a toggle switch
2: I now have a submenu (also manually created) with multiple items which need to be sortable as well.
So when I click on any item it filters. The behavior should be the same as in this demo.
This part, to be specific:
The issue I'm facing is that I don't know if this is possible at all. Yes, I looked at the obvious places but could not find anything helpful. Again, the list is created manually so I'd need some custom function to highjack the instantsearch results, I guess.
Any help is much appreciated.

Backpack crud field that displays an included filtered table

I need to make a new type of field, let's call it included_table. If in Model employees I have a field of type select2 from model Departments, in Departments, I want to have a field of type included_table which displays the table of the employees from that department, in the same way as the crud does.
Is there an easy way of doing this? Or what would be the best way to start?
Thank you.
I don't think there's an easy way to do it. You'd have to code it yourself. You can start from the table field type, put it won't get you very far.
That's because it's a lot more complicated that it looks at first glance. Keep in mind that Backpack create/update forms work with refresh; if you put a table inside one of them, the expected behaviour might be to only "save" the information when you click the final "save" button; but you probably can't do that for the nested entity, because you'd be saving it with AJAX. Plus, you need to build that entire AJAX functionality yourself, including validation. It's not at all more difficult than using plain old Laravel - it's exactly the same. But Backpack won't help very much in this regard.
That being said, you'd probably be better off just putting a button in the list view for each Department, to go edit its employees. That's a lot easier to do, if you follow the nested resources tutorial.
Hope it helps.

GWT Textfield with content assist kind of functionality

I am working on a project and I have a requirement to create one GWT Textfield. User should be able to put query in the text field. But this text field should have content assist (like Ecliplse) kind of functionality.
Example: "path" is one of the predefined object in the application with having certain attribute like "name","address". So now when user type "path.", it should show available attribute. This should work almost same way as in eclipse we get while put objectname it will give all available methods to call.
Example: User writes text "From path.name, path.attribute for object.attribute"
When user writes "from","for" it will not show any assistance but when user types "path." or "object." in above statement, it should show assist.
This is an interesting idea. You could try this with a suggest box widget.
GWT Suggest Box - http://gwt.googleusercontent.com/samples/Showcase/Showcase.html#!CwSuggestBox
GWTChosen Suggest Box - http://jdramaix.github.com/gwtchosen/
The above widget demos work with simple "contains" check on string. You would need to spend some serious logic on the regex matching if you want to pull of your idea.

How can I display another form in a z3c.form button handler?

I have a form with a single text field.
On submit I would like to display another form.
I can use RESPONSE.redirect() and pass it in the query string but I would rather not.
I don't want to use a SESSION variable.
I would like to display a second form which can read this value from the request variable.
I have looked at collective.z3cform.wizard but it is not obvious how to do this.
Trying to call the view() from the button handler does not seem to have any effect.
I fall in the same lack of functionality.
For what I know, z3c.form does not support this kind of traversing.
You may remember that this functionality worked well with CMFFormController.
Actually to do this, cmfformcontroller used session machinery.
So, you don't want to use session but that's the way. At least I do so, and I'm happy.
In this way there's no need of a wrapping tool like z3c.form.wizard.
hth,
alessandro.
collective.singing has a non-session based wizard which uses hidden fields to store results of intermediate steps.