I am attempting to create a front-end form utilising Craft CMS matrix fields and the dropdown/table field options. I have a matrix field called 'course', this has a Block Type called 'course' and this has two fields, 1. 'courseTitle', this is a dropdown field and 2. 'stage1CourseBookingForm' this is a table field, inside this table field I have a column called 'courseType' which is a dropdown. How can I achieve this?
This is my code currently, I get this error: "Impossible to access an attribute ("settings") on a null variable."
{% for block in entry.course %}
{% set entry = entry ?? create('craft\\elements\\Entry') %}
<form method="post" accept-charset="UTF-8">
{{ csrfInput() }}
<input type="hidden" name="action" value="entries/save-entry">
<input type="hidden" name="sectionId" value="1">
<input type="hidden" name="enabled" value="1">
<input type="hidden" name="entryId" value="{{ entry.id }}">
<input type="hidden" name="fields[course]"/>
<input type="hidden" name="fields[course][{{ block.id }}].
[type]" value="course">
<input type="hidden" name="fields[course][{{ block.id }}].
[enabled]" value="1">
{% set dropdownField craft.fields.getFieldbyHandle('courseTitle') %}
<select class="form-control" id="courseTitle" name="fields[courseTitle]">
{% for option in dropdownField.settings.options %}
<option {{ entry.courseTitle.value == option.value? 'selected' : '' }} value="{{ option.value }}">{{ option.label }}</option>
{% endfor %}
</select>`
<button type="submit">Publish</button>
</form>