For single instances of each field, I've successfully followed arajashe's excellent answer for controlling what input fields get displayed in the content type's create/edit form here: https://drupal.stackexchange.com/a/68975/1082 - an answer to question: How do you theme a content type's create/edit form in Drupal 7?
But what about fields where you can add more, where you specify in the settings that more than 1 of a field can be added, or even unlimited.
In this case, the above answer does not work. When I click the 'add more items' button for such fields, in my custom form, the new field does not display. Given that I have already displayed the first instance of the field, I would expect the markup output to include a place holder for contain the new input field that would be inserted as a result of clicking the button.
I've started to debug the code involved - 2 screenshots
The first is in
field.form.inc and shows the ajax call back code - the code that is called when the
add more items button is pressed. This does the job of inserting the markup for the new instance of the field input. For some reason (which is why I'm asking this question), the markup for the second field is not being inserted alongside the first field by this function, when I use a custom template.
The second screenshot shows 2 fields of the same type and the markup that generates them. This is when no custom template is being used - i.e. the default, out-of-the-box input form for add content type that comes with Drupal.